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 network type of the scaling group is VPC. The scaling group and the ALB server group to be associated are in the same virtual private cloud (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 or manually apply for 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
RegionId String Yes cn-hangzhou

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

ScalingGroupId String Yes asg-bp18p2yfxow2dloq****

The ID of the scaling group.

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

The ID of ALB server group N.

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 or manually apply for a quota increase, go to the Quota Center.

AlbServerGroup.N.Port Integer Yes 22

The port number used by the Elastic Compute Service (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 ALB server groups that uses different port numbers with the scaling group. The multiple ALB server groups are the same.
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. The higher the weight of an ECS instance is, the more access requests are distributed to the instance. If the weight is set to 0, the ECS instance does not receive access requests. Valid values: 0 to 100.

N indicates the serial number of the ALB server 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 make sure that it 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 idempotence.

ForceAttach Boolean No false

Specifies whether to add the 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.

Response parameters

Parameter Type Example Description
RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

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 ForceAttach is set to true.

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

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

JSON format

{
        "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.