All Products
Search
Document Center

Auto Scaling:DetachInstances

最終更新日:Nov 11, 2024

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

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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.
OperationAccess levelResource typeCondition keyAssociated operation
ess:DetachInstancesupdate
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ScalingGroupIdstringYes

The ID of the scaling group.

asg-bp1igpak5ft1flyp****
DecreaseDesiredCapacitybooleanNo

Specifies whether to adjust the expected number of instances in the scaling group. Valid values:

  • true: After a specific number of instances are removed from the scaling group, the expected number of instances in the scaling group decreases.
  • false: After a specific number of instances are removed from the scaling group, the expected number of instances in the scaling group remains unchanged.

Default value: true.

true
DetachOptionstringNo

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
InstanceIdsarrayYes

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.

stringYes

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:

  • ECS instance: i-bp109k5j3dum1ce6****
  • Elastic container instance: eci-bp17gw49eu09yiwm****
  • Alibaba Cloud-hosted third-party instance: mi-d23fsd******
Note You can remove only one type of instances at a time.
i-bp109k5j3dum1ce6****
LifecycleHookbooleanNo

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:

  • true
  • false
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
IgnoreInvalidInstancebooleanNo

Specifies whether to ignore invalid instances when you remove a batch of instances from the scaling group. Valid values:

  • true: ignores invalid instances. If invalid instances exist and valid instances are removed from the scaling group, the corresponding scaling activity enters the Warning state. You can check the scaling activity details to view the invalid instances that are ignored.
  • false: does not ignore invalid instances. If invalid instances exist in the batch of instances that you want to remove from the scaling group, an error is reported.

Default value: false.

false
ClientTokenstringNo

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

ParameterTypeDescriptionExample
object
ScalingActivityIdstring

The ID of the scaling activity.

asa-bp1gbswjhjrw8tko****
RequestIdstring

The ID of the request.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

Examples

Sample success responses

JSONformat

{
  "ScalingActivityId": "asa-bp1gbswjhjrw8tko****",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}

Error codes

HTTP status codeError codeError message
500InternalErrorThe 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 timeSummary of changesOperation
2024-05-21The Error code has changed. The request parameters of the API has changedView Change Details