Attaches one or more Classic Load Balancer (CLB, formerly known as SLB) instances to a scaling group.

Description

Before you call this operation to attach a CLB instance to your scaling group, take note of the following items:

  • The CLB instance and the scaling group must belong to the same Alibaba Cloud account.
  • The CLB instance and the scaling group must reside in the same region.
  • The CLB instance must be in the Running state.
  • The CLB instance must be configured with at least one listener. Health check is enabled for the CLB instance.
  • The CLB instance and the scaling group must be in the same virtual private cloud (VPC) if their network type is VPC.
  • If the network type of the scaling group is VPC, the network type of the CLB instance is classic network, and the CLB backend server groups contain instances of the VPC network type, the instances and the scaling group must be in the same VPC.
  • You can attach only a limited number of CLB instances to a scaling group. For more information, see Limits.

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
ActionStringYesAttachLoadBalancers

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

ScalingGroupIdStringYesasg-bp1avr6ensitts3w****

The ID of the scaling group.

ForceAttachBooleanNofalse

Specifies whether to add all instances in the current scaling group to the backend server groups of the attached CLB instance. Valid values:

  • true
  • false

Default value: false.

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 token, but you must make sure that the token 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.

AsyncBooleanNofalse

Specifies whether to perform asynchronous calls to attach CLB instances to the scaling group. Asynchronous calls ensure the transactional nature of operations. This means that the execution results take effect only if all operations are successfully performed. We recommend that you perform asynchronous calls.

Valid values:

  • true: performs asynchronous calls. In this case, the ID of the scaling activity is returned.
  • false: does not perform asynchronous calls.

Default value: false.

LoadBalancer.NStringNolb-2zeur05gfs****

The ID of CLB instance N that you want to attach to the scaling group. Valid values of N: 1 to 5.

LoadBalancerConfig.N.LoadBalancerIdStringNo147b46d767c-cn-qingdao-cm5****

The ID of the CLB instance.

LoadBalancerConfig.N.WeightIntegerNo10

The weight of an Elastic Compute Service (ECS) instance as a backend server in the backend server groups of the attached CLB instance. If you increase the weight of an ECS instance, the number of access requests that are forwarded to the ECS instance also increases. If you set Weight to 0 for an ECS instance, no access requests are forwarded to the ECS instance.

Valid values: 0 to 100.

Response parameters

ParameterTypeExampleDescription
ScalingActivityIdStringasa-bp140qd7mak8k63f****

The ID of the scaling activity.

The value of this parameter is returned only if you set Async to true. You can call the DescribeScalingActivities operation to query the returned IDs of the scaling activities and view the execution status of the scaling activities.

RequestIdString473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

The ID of the request.

Examples

Sample requests

http(s)://ess.aliyuncs.com/?Action=AttachLoadBalancers
&ScalingGroupId=asg-bp1avr6ensitts3w****
&ForceAttach=false
&ClientToken=123e4567-e89b-12d3-a456-42665544****
&Async=false
&LoadBalancer=["lb-2zeur05gfs****"]
&LoadBalancerConfig=[{"LoadBalancerId":"147b46d767c-cn-qingdao-cm5****","Weight":10}]
&<Common request parameters>

Sample success responses

XML format

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

<AttachLoadBalancersResponse>
    <ScalingActivityId>asa-bp140qd7mak8k63f****</ScalingActivityId>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
</AttachLoadBalancersResponse>

JSON format

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

{
  "ScalingActivityId" : "asa-bp140qd7mak8k63f****",
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}

Error codes

For a list of error codes, see Service error codes.

HTTP status code

Error code

Error message

Description

403

Forbidden.Unauthorized

A required authorization for the specified action is not supplied.

Auto Scaling is not authorized to call the operation.

404

InvalidScalingGroupId.NotFound

The specified scaling group does not exist.

The specified scaling group does not exist within the Alibaba Cloud account.

400

QuotaExceeded.LoadBalancer

LoadBalancer quota exceeded in the scaling group "%s".

The maximum number of CLB instances that you can attach to the scaling group exceeds the upper limit.

404

InvalidLoadBalancerId.NotFound

The load balancer "%s" does not exist.

The specified CLB instance does not exist within the Alibaba Cloud account.

400

InvalidLoadBalancerId.RegionMismatch

The load balancer "%s" and the specified scaling group are not in the same Region.

The CLB instance and the scaling group do not reside in the same region.

400

IncorrectLoadBalancerStatus

The current status of the load balancer "%s" does not support this action.

The operation is not supported when the SLB instance is in the current state.

400

IncorrectLoadBalancerHealthCheck

The current health check type of the load balancer "%s" does not support this action.

The health check feature is not enabled for the CLB instance.

400

InvalidLoadBalancerId.VPCMismatch

The specified virtual switch and the instance in the load balancer "%s" are not in the same VPC.

The CLB instance and the scaling group do not reside in the same VPC.

400

QuotaExceeded.BackendServer

Backend server quota exceeded in the load balancer "%s".

The number of backend servers of the CLB instance exceeds the upper limit.

404

InvalidScalingConfigurationId.NotFound

The specified scaling configuration does not exist.

The scaling group has no scaling configuration that is enabled.