Manually add Elastic Compute Service (ECS) instances, elastic container instances, or managed instances to a scaling group.
Usage notes
Before you call this operation, make sure that the following conditions are met:
The specified scaling group is enabled.
The specified scaling group has no scaling activities in progress.
If you want to add ECS instances or elastic container instances to the specified scaling group, make sure that the following conditions are met:
The instances reside in the same region as the scaling group.
The instances are in the Running state.
The instances cannot belong to another scaling group. In other words, the instances must be independent instances.
The instances are billed on a subscription or pay-as-you-go basis, or the instances are preemptible instances.
If VswitchID is specified for the specified 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 specified scaling group.
If VswitchID is not specified for the specified scaling group, the instances that are in VPCs cannot be added to the scaling group.
If you want to add managed instances to the specified scaling group, make sure that the following conditions are met:
The managed instances reside in the same region as the specified scaling group.
The managed instances are independent instances. You can add managed instances to only scaling groups of the ECS type.
The managed instances do not support the lifecycle hook, attachment to Server Load Balancer (SLB), and health check features.
After you add a managed instance to a scaling group of the ECS type, the scaling group does not manage the lifecycle of the managed instance.
You can only manually add managed instances to or remove managed instances from a scaling group. The managed instances that are removed from a scaling group are not released.
When you use this operation, take note of the following items:
If the specified scaling group does not have scaling activities in progress, the operation can bypass the cooldown period of the scaling group and immediately trigger a scaling activity.
A successful call only means that Auto Scaling accepts the request, and does not mean that the scaling activity can succeed. You can obtain the status of a scaling activity based on the value of ScalingActivityId in the response.
The total number of instances in the specified scaling group must be less than or equal to the maximum number of instances that can be included in the scaling group after you call the operation. Otherwise, the operation fails.
The ECS instances, elastic container instances, or managed instances that you manually add to a scaling group by calling the operation are not associated with the active scaling configuration of the scaling group.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | AttachInstances | The operation that you want to perform. Set the value to AttachInstances. |
ScalingGroupId | String | Yes | asg-bp18p2yfxow2dloq**** | The ID of the scaling group. |
Entrusted | Boolean | No | false | Specifies whether the scaling group manages the lifecycles of the instances that are manually added to the scaling group. Valid values:
Note If you call this operation to add subscription instances or managed instances to a scaling group, you must set this parameter to false. Default value: false. |
InstanceId.N | String | No | i-28wt4**** | The ID of ECS instance N, elastic container instance N, or managed instance N that you want to add to the specified scaling group. Valid values of N: 1 to 20. Sample instance IDs:
|
LoadBalancerWeight.N | Integer | No | 50 | The weight of ECS instance N or elastic container instance N as a backend server of the associated SLB instance. Valid values of N: 1 to 20. Valid values of this parameter: 1 to 100. Note This parameter is unavailable in the case that you call this operation to add managed instances to a scaling group. Default value: 50. |
LifecycleHook | Boolean | No | false | Specifies whether to trigger the lifecycle hook when you call this operation. Valid values:
Note This parameter is unavailable in the case that you call this operation to add managed instances to a scaling group. Default value: false. |
RegionId | String | No | cn-qingdao | The region ID of the scaling group. |
Response parameters
Parameter | Type | Example | Description |
ScalingActivityId | String | asa-bp1crxor24s28xf1**** | The ID of the scaling activity. |
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** | The ID of the request. |
Examples
Sample requests
http(s)://ess.aliyuncs.com/?Action=AttachInstances
&ScalingGroupId=asg-bp18p2yfxow2dloq****
&Entrusted=false
&InstanceId=["i-28wt4****"]
&LoadBalancerWeight=[50]
&LifecycleHook=false
&RegionId=cn-qingdao
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<AttachInstancesResponse>
<ScalingActivityId>asa-bp1crxor24s28xf1****</ScalingActivityId>
<RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
</AttachInstancesResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"ScalingActivityId" : "asa-bp1crxor24s28xf1****",
"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 |
404 | InvalidScalingGroupId.NotFound | The specified scaling group does not exist. | The specified scaling group does not exist within the Alibaba Cloud account. |
403 | Forbidden.Unauthorized | A required authorization for the specified action is not supplied. | Auto Scaling is not authorized to call the operation. |
400 | IncorrectScalingGroupStatus | The current status of the specified scaling group does not support this action. | The specified scaling group is not in the Active state. |
404 | InvalidInstanceId.NotFound | Instance "XXX" does not exist. | The specified ECS instance or elastic container instance does not exist within the Alibaba Cloud account. |
400 | InvalidInstanceId. RegionMismatch | Instance "XXX" and the specified scaling group are not in the same Region. | The specified ECS instance or elastic container instance does not reside in the same region as the specified scaling group. |
400 | InvalidInstanceId.InstanceTypeMismatch | Instance "XXX" and existing Active scaling configurations have different instance types. | The instance type of the specified ECS instance or elastic container instance is different from the instance type in the active scaling configuration. |
400 | IncorrectInstanceStatus | The current status of instance "XXX" does not support this action. | The specified ECS instance or elastic container instance is not in the Running state. |
400 | InvalidInstanceId. NetworkTypeMismatch | The network type of instance "XXX" does not support this action. | The network type of the specified ECS instance or elastic container instance is different from the network type of the scaling group. |
400 | InvalidInstanceId.VPCMismatch | Instance "XXX" and the specified scaling group are not in the same VPC. | The specified ECS instance or elastic container instance that you want to add does not reside in the same VPC as the specified scaling group. |
400 | InvalidInstanceId.InUse | Instance "XXX" is already attached to another scaling group. | The specified ECS instance or elastic container instance is already added to another scaling group. |
400 | ScalingActivityInProgress | You cannot delete a scaling group or launch a new scaling activity while there is a scaling activity in progress for the specified scaling group. | The specified scaling group has scaling activities in progress. |
400 | IncorrectLoadBalancerStatus | The current status of the specified load balancer does not support this action. | The SLB instance that is associated with the specified scaling group is not in the Active state. |
400 | IncorrectLoadBalancerHealthCheck | The current health check type of specified load balancer does not support this action. | The health check feature is disabled for the SLB instance that is associated with the specified scaling group. |
400 | InvalidLoadBalancerId.IncorrectInstanceNetworkType | The network type of the instance in specified load balancer does not support this action. | The network type of an ECS instance or elastic container instance that is attached to the specified SLB instance is different from the network type of the scaling group. |
400 | InvalidLoadBalancerId.VPCMismatch | The specified virtual switch and the instance in specified load balancer are not in the same VPC. | An ECS instance or elastic container instance that is attached to the specified SLB instance does not reside in the same VPC as the vSwitch that is specified by VSwitchId. |
400 | IncorrectDBInstanceStatus | The current status of DB instance "XXX" does not support this action. | The ApsaraDB RDS instance that is associated with the specified scaling group is not in the Running state. |
400 | QuotaExceeded.DBInstanceSecurityIP | Security IP quota exceeded in DB instance "XXX". | The maximum number of IP addresses in the IP address whitelist of the ApsaraDB RDS instance that is associated with the specified scaling group has been reached. |
400 | QuotaExceeded.SecurityGroupInstance | Instance quota exceeded in the specified security group. | The maximum number of ECS instances or elastic container instances that are associated with the specified security group has been reached. |
400 | IncorrectCapacity.MaxSize | To attach the instances, the total capacity will be greater than the MaxSize. | The total number of ECS instances or elastic container instances specified by Total Capacity exceeds the value of MaxSize if you call the operation. |