Adds instances to a scaling group to provide services or restarts Elastic Compute Service (ECS) instances stopped in Economical Mode to provide services. You can call the AttachInstances operation to add ECS instances, elastic container instances, or third-party instances managed by Alibaba Cloud to your scaling group to provide services. You can also call this operation to restart ECS instances stopped in Economical Mode in your scaling group to provide services.
Operation description
Before you call this operation, take note of the following items:
- The scaling group is in the Active state.
- No scaling activities in the scaling group are in progress.
The ECS instances or the elastic container instances that you want to add to a scaling group must meet the following requirements:
- The instances reside in the same region as the scaling group.
- The instances must be in the Running state.
- The instances are not added to other scaling groups.
- The instances use the subscription or pay-as-you-go billing method, or are preemptible instances.
- If the VswitchID parameter is specified for a scaling group, the instances that are in the classic network or those that are not in the same virtual private cloud (VPC) as the specified vSwitch cannot be added to the scaling group.
- If the VswitchID parameter is not specified for a scaling group, the instances that are in VPCs cannot be added to the scaling group.
If no scaling activities in the specified scaling group are in progress, the operation can trigger scaling activities even before the cooldown time expires.
A successful call indicates that Auto Scaling accepts the request. However, the scaling activity may still fail. You can obtain the status of a scaling activity by using the value of the ScalingActivityId parameter in the response.
If the sum of the number of instances that you want to add and the number of existing instances in the scaling group is greater than the value of the MaxSize parameter, the call fails.
Instances that are manually added by calling the AttachInstances operation are not associated with the active scaling configuration of the scaling group.
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:AttachInstances | 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-bp18p2yfxow2dloq**** |
Entrusted | boolean | No | Specifies whether to use the scaling group to manage the lifecycles of manually added instances. Valid values:
Note
You cannot specify this parameter for subscription instances, non-Alibaba Cloud instances, and instances in Economical Mode.
Default value: false. | false |
InstanceIds | array | No | The IDs of the ECS instances, elastic container instances, non-Alibaba Cloud instances, or instances in Economical Mode. | |
string | No | The ID of the ECS instance, elastic container instance, non-Alibaba Cloud instance, or instance in Economical Mode. Sample IDs:
Note
You can add only instances of the same type to a scaling group at a time in each call.
| i-28wt4**** | |
LoadBalancerWeights | array | No | The weight of an ECS instance or elastic container instance as a backend server. You can use this parameter to specify weights for multiple instances at the same time. | |
integer | No | The weight of an ECS instance or elastic container instance as a backend server. Valid values: 1 to 100. Note
You cannot specify this parameter for subscription instances and instances in Economical Mode.
Default value: 50. | 50 | |
LifecycleHook | boolean | No | Specifies whether to trigger the lifecycle hook for scale-outs when you call this operation. Valid values:
Note
You cannot specify this parameter for subscription instances and instances in Economical Mode.
Default value: false. | false |
RegionId | string | No | The region ID of the scaling group. | cn-qingdao |
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**** |
Response parameters
Examples
Sample success responses
JSON
format
{
"ScalingActivityId": "asa-bp1crxor24s28xf1****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}
Error codes
HTTP status code | Error code | Error message |
---|---|---|
500 | InternalError | The request processing has failed due to some unknown error, exception or failure. |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|