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

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringYesAttachServerGroups

The operation that you want to perform. Set the value to AttachServerGroups.

RegionIdStringYescn-hangzhou

The region ID of the scaling group.

ScalingGroupIdStringYesasg-bp18p2yfxow2dloq****

The ID of the scaling group.

ClientTokenStringNo123e4567-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.

ForceAttachBooleanNofalse

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:

  • true
  • false

Default value: false.

ServerGroup.N.ServerGroupIdStringYessgp-60ofsqhwer0b***

The ID of backend server group N.

ServerGroup.N.TypeStringYesALB

The type of backend server group N.

Valid values:
  • ALB
  • NLB
ServerGroup.N.WeightIntegerYes100

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.PortIntegerYes22

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

ParameterTypeExampleDescription
ScalingActivityIdStringasa-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.
RequestIdString74C4E313-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.