Attaches load balancers to a scaling group. Auto Scaling supports the attachment of load balancers to scaling groups. Load balancers help distribute the access traffic to the instances in scaling groups, which effectively improves the service performance of the scaling groups. You can call the AttachLoadBalancers operation to attach one or more load balancers to your scaling group.
Operation description
Before you call this operation, make sure that the following requirements are met:
- The load balancer and the scaling group belong to the same Alibaba Cloud account and region.
- The load balancer is in the
Running
state. - At least one listener is configured for the load balancer, and the health check feature is enabled for the load balancer.
- If the network type of the load balancer and the scaling group is virtual private cloud (VPC), they use the same VPC.
- If the network type of the scaling group is VPC, and that of the load balancer is classic network and a backend server of the load balancer uses a VPC, the scaling group and the backend server use the same VPC.
- The attachment of load balancers ensures that the cumulative number of load balancers attached to the scaling group stays within the predefined maximum limit. For information about the load balancer quota, see Limits .
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
ess:AttachLoadBalancers | update | *ScalingGroup acs:ess:{#regionId}:{#accountId}:scalinggroup/{#ScalingGroupId} |
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
ScalingGroupId | string | Yes | The ID of the scaling group. | asg-bp1avr6ensitts3w**** |
ForceAttach | boolean | No | Specifies whether to add the existing instances in the scaling group as backend servers of the load balancer. Valid values:
Default value: false. | false |
ClientToken | string | No | 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 Ensure idempotence. | 123e4567-e89b-12d3-a456-42665544**** |
Async | boolean | No | Specifies whether to attach the CLB instance to the scaling group in an asynchronous manner. If you attach the CLB instance from the scaling group in an asynchronous manner, the call is successful only after all operations are successful. If a specific operation fails, the call fails. We recommend that you set this parameter to true. Valid values:
Default value: false. | false |
LoadBalancers | array | No | The IDs of the load balancers that you want to attach to the scaling group. | |
string | No | The ID of the load balancer that you want to attach to the scaling group. Note
In each call, you can attach up to five load balancers to a scaling group.
| lb-2zeur05gfs**** | |
LoadBalancerConfigs | array<object> | No | The configurations of the classic load balancer (CLB, formerly known as SLB) instance. | |
object | No | |||
LoadBalancerId | string | No | The ID of the CLB instance. | 147b46d767c-cn-qingdao-cm5**** |
Weight | integer | No | The weight of an Elastic Compute Service (ECS) instance or elastic container instance as a backend sever of the CLB instance. If an instance has a higher weight, more access traffic is routed to the instance. If an instance has zero weight, no access traffic is routed to the instance. Valid values: 0 to 100. | 10 |
Response parameters
Examples
Sample success responses
JSON
format
{
"ScalingActivityId": "asa-bp140qd7mak8k63f****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2023-03-30 | The request parameters of the API has changed | View Change Details |