Removes one or more instances from a scaling group. If your scaling group is enabled and contains no ongoing scaling activities, you can call the RemoveInstances operation to remove instances that you no longer require from the 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.
The scaling group does not have ongoing scaling activities.
If the scaling group does not have ongoing scaling activities, you can call the operation even during the cooldown period.
If an Elastic Compute Service (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 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 you want to remove is less than the value of MinSize, the call will fail.
A successful call only indicates that Auto Scaling has accepted the request. It does not guarantee the success of the scaling activity. You can obtain the status of a scaling activity based on the value of ScalingActivityId
in the response.
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 you want Auto Scaling to perform after ECS instances are removed from the scaling group. Valid values:
Default value: release. |
DecreaseDesiredCapacity | Boolean | No | true | Specifies whether to modify the expected number of ECS instances in the scaling group. Valid values:
Default value: true. |
IgnoreInvalidInstance | Boolean | No | false | Specifies whether to ignore invalid instances when a batch of instances is removed from the scaling group. Valid values:
Default value: false. |
InstanceId.N | String | No | i-28wt4**** | The ID of ECS instance N that you want to delete. 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 Ensure idempotence. |
StopInstanceTimeout | Integer | No | 60 | The period of time that is required by ECS instances to enter the Stopped state during the scale-in process. Unit: seconds. Valid values: 30 to 240. Note
|
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
&IgnoreInvalidInstance=false
&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 the 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 of the scaling group to which the specified scaling rule belongs is not in the Active state. |
400 | IncorrectDBInstanceStatus | The current status of DB instance "XXX" does not support this action. | The ApsaraDB RDS instance of the scaling group to which the specified scaling rule belongs 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. |