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.
Operation description
-
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 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 is stopped in economical mode or is released after 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 after the instance is removed from the scaling group.
- If the difference between the number of existing ECS instances specified by the TotalCapacity parameter and the number of ECS instances that you call this operation to remove is less than the value of the MinSize parameter, the call fails.
A successful call only means that Auto Scaling accepts the request. The scaling activity may still fail. You can obtain the status of a scaling activity based on the value of the ScalingActivityId parameter in the response.
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:DetachInstances | 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**** |
RemovePolicy | string | No | The action subsequent to the removal of the Elastic Compute Service (ECS) instances. Valid values:
ScalingPolicy of the CreateScalingGroup operation specifies the reclaim mode of the scaling group while RemovePolicy of the RemoveInstances operation specifies the subsequent action when an ECS instance is removed from the scaling group. Examples:
Default value: release. | release |
DecreaseDesiredCapacity | boolean | No | Specifies whether to adjust the expected number of ECS instances in the scaling group. Valid values:
Default value: true. | true |
IgnoreInvalidInstance | boolean | No | Specifies whether to ignore invalid instances when you remove a batch of instances from the scaling group. Valid values:
Default value: false. | false |
InstanceIds | array | Yes | The IDs of the ECS instances that you want to remove from the scaling group. | |
string | Yes | The ID of the ECS instance that you want to remove from the scaling group. | i-28wt4**** | |
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 How to ensure idempotence. | 123e4567-e89b-12d3-a456-42665544**** |
StopInstanceTimeout | integer | No | The period of time required by the ECS instance to enter the Stopped state. Unit: seconds. Valid values: 30 to 240. Note
| 60 |
Response parameters
Examples
Sample success responses
JSON
format
{
"ScalingActivityId": "asa-bp175o6f6ego3r2j****",
"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 |
---|---|---|
2024-10-16 | The Error code has changed. The request parameters of the API has changed | View Change Details |
2024-05-21 | The Error code has changed. The request parameters of the API has changed | View Change Details |