Removes instances from a scaling group. If an enabled scaling group has no ongoing scaling activities, you can call the DetachInstances operation to remove one or more Elastic Compute Service (ECS) instances, elastic container instances, or Alibaba Cloud-hosted third-party instances from the scaling group.
Operation description
-
Before you call the DetachInstances operation, make sure that the following conditions are met:
- The specified scaling group is enabled.
- The specified scaling group does not have any ongoing scaling activities.
**
Note If the specified scaling group does not have any ongoing scaling activities, the operation can bypass the cooldown period of the scaling group and immediately trigger scaling activities.
-
Before you call this operation, take note of the following items:
- The ECS instances, elastic container instances, or Alibaba Cloud-hosted third-party instances that are removed from a scaling group by using this operation can run independently. If needed, you can call the AttachInstances operation to re-add these instances to a scaling group.
- The ECS instances, elastic container instances, or Alibaba Cloud-hosted third-party instances that are removed from a scaling group by using this operation are not stopped or released.
- A successful call only means that Auto Scaling accepts your request. Scaling activities can be triggered as expected, but their successful execution is not guaranteed. You can query the status of a scaling activity based on the ScalingActivityId response parameter.
- The removal of ECS instances, elastic container instances, or Alibaba Cloud-hosted third-party instances must not result in the overall number of instances within the specified scaling group falling below the minimum capacity threshold (MinSize); otherwise, an error will be reported.
Debugging
Authorization information
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
ScalingGroupId | string | Yes | The ID of the scaling group. | asg-bp1igpak5ft1flyp**** |
DecreaseDesiredCapacity | boolean | No | Specifies whether to adjust the expected number of instances in the scaling group. Valid values:
Default value: true. | true |
DetachOption | string | No | Specifies whether to detach the ECS instances or elastic container instances that are marked for removal from the associated load balancers, and whether to remove the private IP addresses of these instances from the IP address whitelists of the associated ApsaraDB RDS instances. Both: detaches the ECS instances or elastic container instances that are marked for removal from the associated load balancers and removes the private IP addresses of these instances from the IP address whitelists of the associated ApsaraDB RDS instances. Note
This parameter is not supported if you want to remove Alibaba Cloud-hosted third-party instances from a scaling group.
| both |
InstanceIds | array | Yes | The IDs of the ECS instances, elastic container instances, or Aliababa Cloud-managed third-party instances that you want to remove from a scaling group. | |
string | Yes | The ID of the ECS instance, elastic container instance, or Aliababa Cloud-managed third-party instance that you want to remove from a scaling group. Examples:
Note
You can remove only one type of instances at a time.
| i-bp109k5j3dum1ce6**** | |
LifecycleHook | boolean | No | Specifies whether to trigger a lifecycle hook for scale-in purposes when ECS instances or elastic container instances are removed from the scaling group. Valid values:
Note
This parameter is not supported if you want to remove Alibaba Cloud-hosted third-party instances from a scaling group.
Default value: false. | false |
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 |
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 Ensure idempotence. | 123e4567-e89b-12d3-a456-42665544**** |
Response parameters
Examples
Sample success responses
JSON
format
{
"ScalingActivityId": "asa-bp1gbswjhjrw8tko****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}
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-05-21 | The Error code has changed. The request parameters of the API has changed | View Change Details |