All Products
Search
Document Center

Auto Scaling:RemoveInstances

Last Updated:Mar 26, 2024

Removes one or more Elastic Compute Service (ECS) instances or elastic container instances from a 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

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

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

Request parameters

ParameterTypeRequiredDescriptionExample
ScalingGroupIdstringYes

The ID of the scaling group.

asg-bp18p2yfxow2dloq****
RemovePolicystringNo

The action that you want Auto Scaling to perform after the ECS instance is removed from the scaling group. Valid values:

  • recycle: puts the ECS instance into economical mode.

    Note This setting takes effect only if you set the ScalingPolicy parameter to recycle.

  • release: releases the ECS instance.

The ScalingPolicy parameter that you specify when you call the CreateScalingGroup operation specifies the reclaim mode of the scaling group. The RemovePolicy parameter that you specify when you call the RemoveInstances operation specifies the action to be performed on ECS instances after the ECS instances are removed. Example:

  • If you set both the ScalingPolicy parameter and the RemovePolicy parameter to recycle, the ECS instances are put into economical mode after the ECS instances are removed from the scaling group.
  • If you set the ScalingPolicy parameter to recycle and the RemovePolicy parameter to release, the ECS instances are released after the ECS instances are removed from the scaling group.
  • If you set the ScalingPolicy parameter to release and the RemovePolicy parameter to recycle, the ECS instances are released after the ECS instances are removed from the scaling group.
  • If you set both the ScalingPolicy parameter and the RemovePolicy parameter to release, the ECS instances are released after the ECS instances are removed from the scaling group.

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
InstanceIdsarrayYes

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

stringYes

The IDs of the ECS instances that you want to remove from the scaling group. You can specify 1 to 20 IDs.

i-28wt4****
RegionIdstringNo

The region ID of the scaling group.

cn-qingdao

Response parameters

ParameterTypeDescriptionExample
object
ScalingActivityIdstring

The ID of the scaling activity.

asa-bp175o6f6ego3r2j****
RequestIdstring

The ID of the request.

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
No change history