Removes one or more Elastic Compute Service (ECS) instances from a scaling group.

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.

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 enters the economical mode or is released when 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 when the instance is removed from the scaling group.
  • If the difference between the number of existing ECS instances specified by TotalCapacity and the number of ECS instances that you specified to remove is less than the value of MinSize, the call fails.

A successful call indicates that Auto Scaling accepts the request. However, 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. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes RemoveInstances

The operation that you want to perform. Set the value to RemoveInstances.

ScalingGroupId String Yes asg-bp18p2yfxow2dloq****

The ID of the scaling group.

RemovePolicy String No release

The action that is performed when ECS instances are removed. Valid values:

  • recycle: The ECS instances enter the economical mode.
    Note This setting takes effect only if you set ScalingPolicy to recycle.
  • release: The ECS instances are released.

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 when the ECS instances are removed. 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.

DecreaseDesiredCapacity Boolean No true

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

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

Default value: true.

RegionId String No cn-qingdao

The ID of the region where the scaling group resides.

InstanceId.N String Yes i-28wt4****

The ID of ECS instance N that you want to remove. Valid values of N: 1 to 20.

Response parameters

Parameter Type Example Description
ScalingActivityId String asa-bp175o6f6ego3r2j****

The ID of the scaling activity.

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

Examples

Sample requests

http(s)://ess.aliyuncs.com/?Action=RemoveInstances
&ScalingGroupId=asg-bp18p2yfxow2dloq****
&RemovePolicy=release
&DecreaseDesiredCapacity=true
&InstanceId=["i-28wt4****"]
&RegionId=cn-qingdao
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<RemoveInstancesResponse>
    <ScalingActivityId>asa-bp175o6f6ego3r2j****</ScalingActivityId>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
</RemoveInstancesResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

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

Error codes

For a list of error codes, visit the API Error Center.

HTTP status code

Error code

Error message

Description

404

InvalidScalingGroupId.NotFound

The specified scaling group does not exist.

The error message returned because the specified scaling group does not exist within the Alibaba Cloud account.

404

InvalidInstanceId.NotFound

Instance "XXX" does not exist.

The error message returned because the specified ECS instance does not exist in the scaling group.

400

InvalidParameter

The specified group does not support the specified RemovePolicy.

The error message returned because the specified scaling group does not support the RemovePolicy setting.

403

Forbidden.Unauthorized

A required authorization for the specified action is not supplied.

The error message returned because Auto Scaling is not authorized to call the operation.

400

IncorrectScalingGroupStatus

The current status of the specified scaling group does not support this action.

The error message returned because the scaling group is not in the Active state.

400

ScalingActivityInProgress

You cannot delete a scaling group or launch a new scaling activity while there is a scaling activity in progress for the specified scaling group.

The error message returned because a scaling activity is in progress within the scaling group.

400

IncorrectLoadBalancerStatus

The current status of the specified load balancer does not support this action.

The error message returned because the Server Load Balancer (SLB) instance that is associated with the scaling group to which the specified scaling rule applies is not in the Active state.

400

IncorrectDBInstanceStatus

The current status of DB instance "XXX" does not support this action.

The error message returned because the ApsaraDB RDS instance that is associated with the scaling group to which the specified scaling rule applies is not in the Running state.

400

IncorrectCapacity.MinSize

To remove the instances, the total capacity will be lesser than the MinSize.

The error message returned because the difference between the number of existing ECS instances specified by TotalCapacity and the number of ECS instances that you specified to remove is less than the value of MinSize.