Associates one or more Application Load Balancer (ALB) server groups with a scaling group.

Description

Before you associate an ALB server group with a scaling group, make sure that the following requirements are met:

  • The scaling group resides in a virtual private cloud (VPC). The scaling group and the ALB server group that you want to associate must reside in the same VPC.
  • The ALB server group is in the Available state.
  • You can associate only a limited number of ALB server groups with a scaling group. To view the available quota or manually request a quota increase, go to the Quota Center.

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

Parameter Type Required Example Description
Action String Yes AttachAlbServerGroups

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

RegionId String Yes cn-hangzhou

The ID of the region to which the scaling group belongs, such as cn-hangzhou and cn-shanghai. For more information, see Regions and zones.

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 it is unique among different requests. The token can only contain ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

ForceAttach Boolean No false

Specifies whether to add the Elastic Compute Service (ECS) instances in the scaling group to the newly associated ALB server group.

  • true: adds the ECS instances and returns the ScalingActivityId value. You can view the ID of the scaling activity to determine whether the existing instances are added.
  • false: does not add the ECS instances.

Default value: false.

AlbServerGroup.N.AlbServerGroupId String Yes sgp-ddwb0y0g6y9bjm****

The ID of the ALB server group.

N indicates the serial number of the ALB server group. You can associate only a limited number of ALB server groups with a scaling group. To view the available quota or manually request a quota increase, go to the Quota Center.

AlbServerGroup.N.Weight Integer Yes 100

The weight of the ECS instance as a backend server after the instance is added to the ALB server group. If you increase the weight of an ECS instance, the number of access requests that are forwarded to the ECS instance increases. If you set the weight to 0, no access requests are forwarded to the ECS instance. Valid values: 0 to 100.

N indicates the serial number of the ALB server group.

AlbServerGroup.N.Port Integer Yes 22

The port number used by the ECS instance after the instance is added to ALB server group N. Valid values: 1 to 65535.

N indicates the serial number of the ALB server group.

Note If the N values are the same but the port numbers are different, the system associates multiple ports in the scaling group with ALB server group N.

Response parameters

Parameter Type Example Description
ScalingActivityId String asa-2ze6wxj8vsohn6j9****

The ID of the scaling activity in which Auto Scaling associates the ALB server group with the scaling group and adds ECS instances in the scaling group to the ALB server group. This parameter is valid only when you set ForceAttach to true.

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

Examples

Sample requests

http(s)://ess.aliyuncs.com/?Action=AttachAlbServerGroups
&RegionId=cn-hangzhou
&ScalingGroupId=asg-bp18p2yfxow2dloq****
&AlbServerGroup.1.AlbServerGroupId=sgp-ddwb0y0g6y9bjm****
&AlbServerGroup.1.Port=22
&AlbServerGroup.1.Weight=100
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<AttachAlbServerGroupsResponse>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
    <ScalingActivityId>asa-2ze6wxj8vsohn6j9****</ScalingActivityId>
</AttachAlbServerGroupsResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
  "ScalingActivityId" : "asa-2ze6wxj8vsohn6j9****"
}

Error codes

For a list of error codes, visit the API Error Center.

HTTP status code

Error code

Error message

Description

400

AlbServerGroup.NotExist

The ServerGroup "%s" do(es) not exist.

The error message returned because the specified ALB server group does not exist within the account.

400

AlbServerGroup.AlreadyAttached

The ALB ServerGroups are already attached.

The error message returned because the ALB server group is already associated with the scaling group.