All Products
Search
Document Center

Auto Scaling:AttachInstances

Last Updated:Sep 10, 2026

Manually adds ECS instances to a scaling group.

Operation description

Operation description

  • Before you invoke this operation, make sure that the following conditions are met:

    • The scaling group is in the Active state.

    • No scaling activity is in progress in the scaling group.

  • The following limits apply to ECS instances or Elastic Container Instance (ECI) instances that you want to add to a scaling group: - The instances must be in the same region as the scaling group. - The instances must be in the Running state. - The instances cannot already belong to another scaling group. - The payer of the instances must be subscription, pay-as-you-go, or spot instance. - If the scaling group has a specified VswitchID, ECS instances or ECI instances of the Classic network type cannot be added to the scaling group. ECS instances or ECI instances in a different VPC cannot be added to the scaling group either. - If the scaling group does not have a specified VswitchID, ECS instances or ECI instances of the VPC network type cannot be added to the scaling group.

  • The following limits apply to managed instances that you want to add to a scaling group:

    • The managed instances must be in the same region as the scaling group.

    • Only managed instances that do not belong to a scaling group can be added to an ECS-type scaling group.

    • Managed instances do not support lifecycle hooks, load balancing association, or health check features.

    • After managed instances are added to an ECS-type scaling group, the scaling group does not manage the lifecycle of the managed instances.

    • Managed instances can only be manually added to or removed from a scaling group. Managed instances are not released after they are removed.

  • Take note of the following items when you invoke this operation:

    • When no scaling activity is in progress in the scaling group, this operation can bypass the cooldown time (Cooldown) and be executed immediately.

    • A successful invocation only indicates that Auto Scaling has accepted the request. The scaling activity can be executed, but a successful invocation does not guarantee that the scaling activity will succeed. You can check the execution status of the scaling activity based on the returned ScalingActivityId.

    • If the number of instances specified in this operation plus the current number of instances in the scaling group (Total Capacity) exceeds the maximum size (MaxSize), the invocation is failed.

    • ECS instances, ECI instances, or managed instances that are manually added by invoking this operation are not associated with the active scaling configuration of the scaling group.

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

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request parameters

Parameter

Type

Required

Description

Example

ScalingGroupId

string

Yes

The ID of the scaling group.

asg-bp18p2yfxow2dloq****

Entrusted

boolean

No

Specifies whether to entrust the lifecycle of the instance to the scaling group when you manually add an existing instance to the scaling group. Valid values:

  • true: The lifecycle of the instance is managed by Auto Scaling, consistent with instances that are created through automatic creation by the scaling group. The instance is subject to automatic release when it is removed from the scaling group, except when it is removed by invoking the DetachInstances operation.

  • false: The lifecycle of the instance is not managed by the scaling group. The instance is not released when it is removed from the scaling group.

Note

Settings for this parameter are not supported for subscription instances, managed instances, or instances in the economy mode (stopped) state within the scaling group.

Default value: false.

false

InstanceId

array

No

Instance ID of the ECS instance, ECI instance, managed instance, or instance in the economy mode (stopped) state within the scaling group that you want to add. Valid values of N: 1 to 20.

Examples:

  • Instance ID of the ECS instance to add: i-28wt4****.

  • Instance ID of the ECI instance to add: eci-bp17gw49eu09yiwm****.

  • Instance ID of the managed instance to add: mi-2cx*****.

  • Instance ID of the instance in the economy mode (stopped) state within the scaling group to restart: i-2cd2f****.

Note

Only one type of instance can be processed in a single request.

i-28wt4****

string

No

Instance ID of the ECS instance, ECI instance, managed instance, or instance in the economy mode (stopped) state within the scaling group that you want to add. Valid values of N: 1 to 20.

Examples:

  • Instance ID of the ECS instance to add: i-28wt4****.

  • Instance ID of the ECI instance to add: eci-bp17gw49eu09yiwm****.

  • Instance ID of the managed instance to add: mi-2cx*****.

  • Instance ID of the instance in the economy mode (stopped) state within the scaling group to restart: i-2cd2f****.

Note

Only one type of instance can be processed in a single request.

i-28wt4****

LoadBalancerWeight

array

No

The weight of the ECS instance or ECI instance as a backend server of the load balancing instance.

Note

Settings for this parameter are not supported for managed instances or instances in the economy mode (stopped) state within the scaling group.

50

integer

No

The weight of the ECS instance or ECI instance as a backend server of the load balancing instance. Valid values of N: 1 to 20. Valid values of this parameter: 1 to 100.

Note

Settings for this parameter are not supported for managed instances or instances in the economy mode (stopped) state within the scaling group.

Default value: 50.

50

LifecycleHook

boolean

No

Specifies whether to trigger a scale-out lifecycle hook when instances are added to the scaling group. Valid values:

  • true: triggers the lifecycle hook.

  • false: does not trigger the lifecycle hook.

Note

This parameter is not supported for managed instances or instances in the economy mode (stopped) state within the scaling group.

Default value: false.

false

RegionId

string

No

The region ID of the scaling group.

cn-qingdao

ClientToken

string

No

The client token that is used to ensure the idempotence of the request.

You can use the client to generate the token, but 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****

IgnoreInvalidInstance

boolean

No

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

  • true: Invalid instances are ignored when a batch of instances is added to the scaling group. If invalid instances exist and valid instances are successfully added, the scaling activity status 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 added to the scaling group. If any invalid instance exists in the batch, the request returns an error.

Default value: false.

false

Response elements

Element

Type

Description

Example

object

ScalingActivityId

string

The ID of the scaling activity.

asa-bp1crxor24s28xf1****

RequestId

string

The request ID.

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

Examples

Success response

JSON format

{
  "ScalingActivityId": "asa-bp1crxor24s28xf1****",
  "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.