You can call this operation to remove one or more ECS instances from a scaling group.

Description

Before you call this operation, ensure that the following requirements are met:

  • The scaling group is in the Active state.
  • The scaling group does not have any scaling activities in progress.

If the scaling group does not have any scaling activities in progress, the operation can be immediately executed without waiting for the cooldown period to expire.

When an automatically created ECS instance is removed from a scaling group, the instance is stopped and released.

When a manually added ECS instance is removed from a scaling group, the ECS instance is neither stopped nor released.

When this operation is called, Auto Scaling receives the request. However, it is not guaranteed that the scaling activity can be run as intended. You can use the returned ScalingActivityId parameter to check the status of the scaling activity.

When the difference between the number of existing ECS instances in the scaling group (Total Capacity) and the number of ECS instances to be removed is less than the MinSize value, the call fails.

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
InstanceId.N RepeatList Yes i-28wt4****

The IDs of ECS instances to be removed. Valid values of N: 1 to 20.

ScalingGroupId String Yes AG6CQdPU8OKdwLjgZcJ****

The ID of the scaling group.

Action String Yes RemoveInstances

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

DecreaseDesiredCapacity Boolean No true

Specifies whether to modify the expected number of instances. Valid values:

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

Default value: true

RemovePolicy String No release

Specifies the policy used to remove an instance. Valid values:

  • recycle: indicates that the instance is stopped and then removed.
    Note The value takes effect only when the ScalingPolicy parameter is set to recycle.
  • release: indicates that the instance is removed and then released.

Default value: release

Response parameters

Parameter Type Example Description
RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

ScalingActivityId String bybj9OcaOT4ucPMbFhcq****

The ID of the scaling activity.

Examples

Sample requests


http://ess.aliyuncs.com/?Action=RemoveInstances
&ScalingGroupId=AG6CQdPU8OKdwLjgZcJ****
&InstanceId.1=i-28wt4****
&<Common request parameters>

Sample success responses

XML format

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

JSON format

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

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.

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 specified value of the RemovePolicy parameter.

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 specified operation.

400

IncorrectScalingGroupStatus

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

The error message returned because the specified scaling group is not active.

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 the specified scaling group has a scaling activity in progress.

400

IncorrectLoadBalancerStatus

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

The error message returned because an SLB instance for the scaling group to which the specified scaling rule belongs is not active.

400

IncorrectDBInstanceStatus

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

The error message returned because an ApsaraDB for RDS instance for the scaling group to which the specified scaling rule belongs is not running.

400

IncorrectCapacity.MinSize

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

The error message because the number of ECS instances to be removed would leave the number of ECS instances in the specified scaling group less than the MinSize value.