DetachInstances

Updated at:

Removes one or more ECS instances from a scaling group.

Operation description

Operation description

  • Before calling this operation, ensure that the following conditions are met:

    • The target scaling group must be in the Enabled state.

    • The target scaling group does not have ongoing scaling activities.

      Note

      If the target scaling group does not have ongoing scaling activities, this operation can bypass the cooldown time and directly trigger a scaling activity.

  • Note the following when using this operation:

    • After an ECS instance, an ECI instance, or a managed instance is removed, the instance can exist independently of the scaling group. You can call the AttachInstances operation to add the ECS instance, ECI instance, or managed instance to another scaling group.

    • Calling this operation to remove an ECS instance, an ECI instance, or a managed instance does not stop or release the instance.

    • A successful call to this operation only indicates that Auto Scaling has accepted the request. A scaling activity can be triggered normally, but the success of the scaling activity is not guaranteed. You must check the status of the scaling activity by using the returned ScalingActivityId.

    • The number of ECS instances, ECI instances, or managed instances in the target scaling group minus the number of instances to be removed cannot be less than the minimum number of instances (MinSize) in the scaling group. Otherwise, an error is reported.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ess:DetachInstances

update

*ScalingGroup

acs:ess:{#regionId}:{#accountId}:scalinggroup/{#ScalingGroupId}

None None

Request parameters

Parameter

Type

Required

Description

Example

ScalingGroupId

string

Yes

The ID of the scaling group.

asg-bp1igpak5ft1flyp****

DecreaseDesiredCapacity

boolean

No

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

  • true: After the ECS instances, ECI instances, or managed instances are removed from the scaling group, the expected number of instances is decreased by the corresponding number.

  • false: After the ECS instances, ECI instances, or managed instances are removed from the scaling group, the expected number of instances remains unchanged.

Default value: true.

true

IgnoreInvalidInstance

boolean

No

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

  • true: Invalid instances are ignored when a batch of instances is removed from the scaling group.

    If invalid instances exist in the batch (for example, the instance status is Adding) and the valid instances are successfully removed, the execution status of the scaling activity is displayed as Warning. You can view the invalid instances in the scaling activity details.

  • false: Invalid instances are not ignored when a batch of instances is removed from the scaling group.

    If invalid instances exist in the batch (for example, the instance status is Adding), an error is returned.

Default value: false.

false

DetachOption

string

No

Specifies whether to stop using the ECS instances or ECI instances as backend servers of the load balancing instances (that is, remove the ECS instances or ECI instances from the default server group and virtual server group of the load balancing instances), and whether to remove the ECS instances or ECI instances from the access whitelists of the ApsaraDB RDS instances.

Valid values:

both: Removes the ECS instances or ECI instances from the default server group and virtual server group of the load balancing instances, and removes the ECS instances or ECI instances from the access whitelists of the ApsaraDB RDS instances.

Note

Settings for this parameter are not supported when managed instances are removed from the scaling group.

both

InstanceId

array

Yes

The IDs of the ECS instances, ECI instances, or managed instances to be removed.

i-bp109k5j3dum1ce6****

string

No

Instance ID of the ECS instance, ECI instance, or managed instance to be removed. Valid values of N: 1 to 20.

Examples:

  • Instance ID of the ECS instance to be removed is i-bp109k5j3dum1ce6****.

  • Instance ID of the ECI instance to be removed is eci-bp17gw49eu09yiwm****.

  • Instance ID of the managed instance to be removed is mi-d23fsd******.

Note

You can remove only one type of instance in a single call.

i-bp109k5j3dum1ce6****

LifecycleHook

boolean

No

Specifies whether to trigger the scale-in lifecycle hook when ECS instances or ECI instances are removed from the scaling group. Valid values:

  • true: Triggers the hook.

  • false: Does not trigger the hook.

Note

This parameter is not supported when managed instances are removed from the scaling group.

Default value: false.

false

ClientToken

string

No

Ensures the idempotence of the request.

You can generate a parameter value from your client to ensure that the value is unique across different requests. The value can only contain ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

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

Response elements

Element

Type

Description

Example

object

ScalingActivityId

string

The ID of the scaling activity.

asa-bp1gbswjhjrw8tko****

RequestId

string

The ID of the request.

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

Examples

Success response

JSON format

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

Error codes

HTTP status code

Error code

Error message

Description

500 InternalError The request processing has failed due to some unknown error, exception or failure.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.