Attaches one or more Server Load Balancer (SLB) instances to a scaling group. You can attach the following types of SLB instances to a scaling group: Application Load Balancer (ALB) instances and Network Load Balancer (NLB) instances.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | AttachServerGroups | The operation that you want to perform. Set the value to AttachServerGroups. |
RegionId | String | Yes | cn-hangzhou | The region ID of the scaling group. |
ScalingGroupId | String | Yes | asg-bp18p2yfxow2dloq**** | The ID of the scaling group. |
ClientToken | String | No | 123e4567-e89b-12d3-a456-42665544**** | The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must ensure that the value is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure the idempotence of a request. |
ForceAttach | Boolean | No | false | Specifies whether to add the Elastic Compute Service (ECS) instances in the scaling group to the backend server group of the newly attached SLB instance. Valid values:
Default value: false. |
ServerGroup.N.ServerGroupId | String | Yes | sgp-60ofsqhwer0b*** | The ID of backend server group N. |
ServerGroup.N.Type | String | Yes | ALB | The type of backend server group N. Valid values:
|
ServerGroup.N.Weight | Integer | Yes | 100 | The weight of an ECS instance in the scaling group as a backend server after Auto Scaling adds the ECS instance to backend server group N. Valid values: 0 to 100. If you increase the weight of an ECS instance in a backend server group, the number of access requests that are forwarded to the ECS instance increases. If you set the Weight parameter for an ECS instance in a backend server group to 0, no access requests are forwarded to the ECS instance. |
ServerGroup.N.Port | Integer | Yes | 22 | The port number used by an ECS instance in the scaling group after Auto Scaling adds the ECS instance to backend server group N. Valid values: 1 to 65535. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
ScalingActivityId | String | asa-bp1c9djwrgxjyk31**** | The ID of the scaling activity during which one or more SLB instances are attached to the scaling group and the ECS instances in the scaling group are added to the backend server groups of the SLB instances. Note This parameter is returned only after you set the ForceAttach parameter to true . |
RequestId | String | 74C4E313-8570-479F-8791-DC25360D**** | The ID of the request. |
Examples
Sample requests
http(s)://ess.aliyuncs.com/?Action=AttachServerGroups
&RegionId=cn-hangzhou
&ScalingGroupId=asg-bp18p2yfxow2dloq****
&ClientToken=123e4567-e89b-12d3-a456-42665544****
&ForceAttach=false
&ServerGroup=[{"ServerGroupId":"sgp-60ofsqhwer0b***","Type":"ALB","Weight":100,"Port":22}]
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<AttachServerGroupsResponse>
<ScalingActivityId>asa-bp1c9djwrgxjyk31****</ScalingActivityId>
<RequestId>74C4E313-8570-479F-8791-DC25360D****</RequestId>
</AttachServerGroupsResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"ScalingActivityId" : "asa-bp1c9djwrgxjyk31****",
"RequestId" : "74C4E313-8570-479F-8791-DC25360D****"
}
Error codes
For a list of error codes, see Service error codes.