Removes one or more Elastic Compute Service (ECS) instances from a scaling group.
Usage notes
Before you call this operation, make sure that the following requirements are met:
The scaling group is in the Active state.
No scaling activity is in progress within the scaling group.
If no scaling activity is in progress within the scaling group, you can call the operation even within the cooldown period.
If an ECS instance is automatically created by Auto Scaling, or if an ECS instance is manually added to a scaling group and managed by the scaling group, the ECS instance enters the economical mode or is released when the instance is removed from the scaling group.
If an ECS instance is manually added to a scaling group and is not managed by the scaling group, the ECS instance is not stopped or released when the instance is removed from the scaling group.
If the difference between the number of existing ECS instances specified by TotalCapacity and the number of ECS instances that you specified to remove is less than the value of MinSize, the call fails.
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 return value of ScalingActivityId.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | RemoveInstances | The operation that you want to perform. Set the value to RemoveInstances. |
ScalingGroupId | String | Yes | asg-bp18p2yfxow2dloq**** | The ID of the scaling group. |
RemovePolicy | String | No | release | The action that is performed when ECS instances are removed. Valid values:
Default value: release. |
DecreaseDesiredCapacity | Boolean | No | true | Specifies whether to modify the expected number of instances in the scaling group. Valid values:
Default value: true. |
InstanceId.N | String | No | i-28wt4**** | The ID of ECS instance N that you want to remove. Valid values of N: 1 to 20. |
RegionId | String | No | cn-qingdao | The region ID of the scaling 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 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 the idempotence. |
Response parameters
Parameter | Type | Example | Description |
ScalingActivityId | String | asa-bp175o6f6ego3r2j**** | 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=RemoveInstances
&ScalingGroupId=asg-bp18p2yfxow2dloq****
&RemovePolicy=release
&DecreaseDesiredCapacity=true
&InstanceId=["i-28wt4****"]
&RegionId=cn-qingdao
&ClientToken=123e4567-e89b-12d3-a456-42665544****
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<RemoveInstancesResponse>
<ScalingActivityId>asa-bp175o6f6ego3r2j****</ScalingActivityId>
<RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
</RemoveInstancesResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"ScalingActivityId" : "asa-bp175o6f6ego3r2j****",
"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 your Alibaba Cloud account. |
404 | InvalidInstanceId.NotFound | Instance "XXX" does not exist. | The specified ECS instance does not exist in the scaling group. |
400 | InvalidParameter | The specified group does not support the specified RemovePolicy. | The specified scaling group does not support the RemovePolicy setting. |
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 scaling group is not in the Active state. |
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 scaling group has a scaling activity in progress. |
400 | IncorrectLoadBalancerStatus | The current status of the specified load balancer does not support this action. | The Server Load Balancer (SLB) instance that is associated with the scaling group to which the specified scaling rule applies is not in the Active state. |
400 | IncorrectDBInstanceStatus | The current status of DB instance "XXX" does not support this action. | The ApsaraDB RDS instance that is associated with the scaling group to which the specified scaling rule applies is not in the Running state. |
400 | IncorrectCapacity.MinSize | To remove the instances, the total capacity will be lesser than the MinSize. | The difference between the number of existing ECS instances specified by TotalCapacity and the number of ECS instances that you specified to remove is less than the value of MinSize. |