All Products
Search
Document Center

Auto Scaling:RemoveInstances

Last Updated:Dec 17, 2024

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.
Note If no scaling activity is in progress within the scaling group, you can call the operation even within the cooldown period.
  • 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

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
*ScalingGroup
acs:ess:{#regionId}:{#accountId}:scalinggroup/{#ScalingGroupId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ScalingGroupIdstringYes

The ID of the scaling group.

asg-bp18p2yfxow2dloq****
RemovePolicystringNo

The action subsequent to the removal of the Elastic Compute Service (ECS) instances. Valid values:

  • recycle: The ECS instances enter the Economical Mode.

    **

    Note This setting is applicable only if you set ScalingPolicy to recycle.

  • release: The ECS instances are released.

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:

  • If you set ScalingPolicy and RemovePolicy to recycle, the ECS instances enter the Economical Mode when they are removed.
  • If you set ScalingPolicy to recycle and RemovePolicy to release, the ECS instances are released when they are removed.
  • If you set ScalingPolicy to release and RemovePolicy to recycle, the ECS instances are released when they are removed.
  • If you set ScalingPolicy and RemovePolicy to release, the ECS instances are released when they are removed.

Default value: release.

release
DecreaseDesiredCapacitybooleanNo

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

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

Default value: true.

true
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 deleted, 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
InstanceIdsarrayYes

The IDs of the ECS instances that you want to remove from the scaling group.

stringYes

The ID of the ECS instance that you want to remove from the scaling group.

i-28wt4****
RegionIdstringNo

The region ID of the scaling group.

cn-qingdao
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 How to ensure idempotence.

123e4567-e89b-12d3-a456-42665544****
StopInstanceTimeoutintegerNo

The period of time required by the ECS instance to enter the Stopped state. Unit: seconds. Valid values: 30 to 240.

Note
  • By default, this parameter inherits the value of StopInstanceTimeout specified in the CreateScalingGroup or ModifyScalingGroup operation. You can also specify a different value for this parameter in the RemoveInstances operation.

  • This parameter takes effect only if you set RemovePolicy to release.

  • If you specify this parameter, the system waits for the ECS instance to enter the Stopped state only for up to the specified period of time before continuing with the scale-in operation, regardless of the status of the ECS instance.

  • If you do not specify this parameter, the system continues with the scale-in operation until the ECS instance enters the Stopped state. If the ECS instance is not successfully stopped, the scale-in process is rolled back and considered failed.

60

Response parameters

ParameterTypeDescriptionExample
object
ScalingActivityIdstring

The ID of the scaling activity.

asa-bp175o6f6ego3r2j****
RequestIdstring

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Examples

Sample success responses

JSONformat

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

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-10-16The Error code has changed. The request parameters of the API has changedView Change Details
2024-05-21The Error code has changed. The request parameters of the API has changedView Change Details