RemoveInstances
Deletes one or more unnecessary instances from a scaling group if the scaling group is enabled and no scaling activity is being executed. You can invoke the RemoveInstances API operation to delete these instances.
Operation description
Operation description
-
Before you invoke this operation, make sure that the following conditions are met:
-
The scaling group is enabled (Active).
-
No scaling activity is being executed in the scaling group.
-
If no scaling activity is being executed in the scaling group, this operation can bypass the cooldown time (DefaultCooldown) and be executed directly.
-
If an ECS instance is from automatic creation by Auto Scaling, or was manually added and managed by the scaling group, the ECS instance triggers the economical mode or is released when you delete the ECS instance from the scaling group.
-
If an ECS instance was manually added and is not managed by the scaling group, the ECS instance is not stopped or released when you delete the ECS instance from the scaling group.
-
If the current number of instances in the scaling group (TotalCapacity) minus the number of instances specified in this operation is less than the minimum number of instances in the scaling group (MinSize), the invoke request failed.
A successful response only indicates that the Auto Scaling service has accepted the invoke request and the scaling activity can be executed. It does not mean that the scaling activity will be executed successfully. You must use the returned ScalingActivityId to check the execute status of the scaling activity.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ess:DetachInstances |
update |
*ScalingGroup
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| ScalingGroupId |
string |
Yes |
The ID of the scaling group. |
asg-bp18p2yfxow2dloq**** |
| RemovePolicy |
string |
No |
Specifies the action to be performed on the removed ECS instances. Valid values:
Default value: release. |
release |
| DecreaseDesiredCapacity |
boolean |
No |
Specifies whether to modify the expected number of instances. Valid values:
Default value: true. |
true |
| IgnoreInvalidInstance |
boolean |
No |
Specifies whether to ignore invalid instances when deleting a batch of instances from the scaling group. Valid values:
Default value: false. |
false |
| InstanceId |
array |
Yes |
The ID of the ECS instance to be removed. |
i-28wt4**** |
|
string |
No |
The ID of the ECS instance to be removed. Valid values of N: 1 to 20. |
i-28wt4**** |
|
| RegionId |
string |
No |
The region ID of the scaling group. |
cn-qingdao |
| ClientToken |
string |
No |
Ensures the idempotence of the request. You can generate a parameter value from your client to ensure that the value is unique among different requests. The value can only contain 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 timeout period for waiting for the ECS instance to be stopped during the scale-in process. Unit: seconds. Valid values: 30 to 240. Note
|
60 |
| LifecycleHookContext |
object |
No |
The context information of the lifecycle hook. |
|
| DisableLifecycleHook |
boolean |
No |
Specifies whether to disable all lifecycle hooks for the scaling activity. Valid values:
|
false |
| IgnoredLifecycleHookIds |
array |
No |
The IDs of the lifecycle hooks disabled for the scaling activity. |
|
|
string |
No |
The IDs of the lifecycle hooks disabled for the scaling activity. |
ash-bp14zolna43z266bq*** |
|
| LifecycleHookResult |
string |
No |
The default execution result of the lifecycle hook in this scaling activity. If specified, this value overwrites the original default execution result of the hook. |
CONTINUE |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| ScalingActivityId |
string |
The ID of the scaling activity. |
asa-bp175o6f6ego3r2j**** |
| RequestId |
string |
The request ID. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
| IgnoredInstances |
object |
||
| IgnoredInstance |
array<object> |
The list of instances ignored due to invalidity. |
|
|
object |
The information about an instance ignored due to invalidity. |
||
| InstanceId |
string |
The instance ID of the ignored instance. |
i-invalidcodextest12345 |
| Code |
string |
The code indicating the reason why the instance is ignored. |
InvalidInstanceId.NotFound |
| Message |
string |
The description of the reason why the instance is ignored. |
The specified instance does not exist. |
Examples
Success response
JSON format
{
"ScalingActivityId": "asa-bp175o6f6ego3r2j****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
"IgnoredInstances": {
"IgnoredInstance": [
{
"InstanceId": "i-invalidcodextest12345",
"Code": "InvalidInstanceId.NotFound",
"Message": "The specified instance does not exist."
}
]
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 500 | InternalError | The request processing has failed due to some unknown error, exception or failure. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.