If a scaling group is enabled and has no ongoing scaling activities, you can call the RemoveInstances API to remove one or more instances from the group.
Operation description
- Ensure the following conditions are met before you call this API:
The scaling group is in the Active state.
The scaling group has no scaling activities in progress.
This API can bypass the cooldown (DefaultCooldown) if the scaling group has no ongoing scaling activities.
If an ECS instance is automatically created by Auto Scaling, or is manually added and managed by the scaling group, removing the instance from the scaling group places it in Economical Mode or releases it.
If an ECS instance is manually added and not managed by the scaling group, removing the instance from the group does not stop or release it.
The call fails if the number of remaining instances would fall below the minimum number of instances (
MinSize).
A successful response confirms the Auto Scaling service has accepted the request, but does not guarantee the scaling activity will succeed. You must use the returned ScalingActivityId to check the execution 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 take on removed ECS instances. Valid values:
The
Default value: release. |
release |
| DecreaseDesiredCapacity |
boolean |
No |
Specifies whether to decrease the desired capacity of the scaling group. Valid values:
Default value: true. |
true |
| IgnoreInvalidInstance |
boolean |
No |
Specifies whether to ignore invalid instances when you remove multiple instances from a scaling group. Valid values:
Default value: false. |
false |
| InstanceIds |
array |
Yes |
The IDs of the ECS instances to remove. |
|
|
string |
No |
The ID of an ECS instance to remove. |
i-28wt4**** |
|
| RegionId |
string |
No |
The region ID of the scaling group. |
cn-qingdao |
| ClientToken |
string |
No |
A client-generated token to ensure request idempotence. This token must be unique for each request, contain only ASCII characters, and not exceed 64 characters. For more information, see How to ensure idempotence. |
123e4567-e89b-12d3-a456-42665544**** |
| StopInstanceTimeout |
integer |
No |
The timeout period, in seconds, for an ECS instance to stop during a scale-in. Valid values: 30 to 240. Note
|
60 |
| LifecycleHookContext |
object |
No |
The context of the lifecycle hook. |
|
| DisableLifecycleHook |
boolean |
No |
Specifies whether to disable all lifecycle hooks for the scaling activity. Valid values:
|
false |
| IgnoredLifecycleHookIds |
array |
No |
A list of lifecycle hook IDs to ignore for the scaling activity. |
|
|
string |
No |
The ID of a lifecycle hook to ignore for the scaling activity. |
ash-bp14zolna43z266bq*** |
|
| LifecycleHookResult |
string |
No |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| ScalingActivityId |
string |
The ID of the scaling activity. |
asa-bp175o6f6ego3r2j**** |
| RequestId |
string |
The ID of the request. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
| IgnoredInstances |
array<object> |
The instances that were not removed and the reasons why they were not removed. |
|
|
object |
|||
| InstanceId |
string |
The ID of the instance that was not removed. |
|
| Code |
string |
The error code that indicates the reason why the instance was not removed. |
|
| Message |
string |
The error message that indicates the reason why the instance was not removed. |
Examples
Success response
JSON format
{
"ScalingActivityId": "asa-bp175o6f6ego3r2j****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
"IgnoredInstances": [
{
"InstanceId": "",
"Code": "",
"Message": ""
}
]
}
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.