All Products
Search
Document Center

Auto Scaling:AttachInstances

Last Updated:Feb 28, 2024

Adds Elastic Compute Service (ECS) instances, elastic container instances, or managed instances to a scaling group.

Operation description

Before you call this operation, take note of the following items:

  • The scaling group is in the Active state.
  • No scaling activities in the scaling group are in progress.

The ECS instances or the elastic container instances that you want to add to a scaling group must meet the following requirements:

  • The instances reside in the same region as the scaling group.
  • The instances must be in the Running state.
  • The instances are not added to other scaling groups.
  • The instances use the subscription or pay-as-you-go billing method, or are preemptible instances.
  • If the VswitchID parameter is specified for a scaling group, the instances that are in the classic network or those that are not in the same virtual private cloud (VPC) as the specified vSwitch cannot be added to the scaling group.
  • If the VswitchID parameter is not specified for a scaling group, the instances that are in VPCs cannot be added to the scaling group.

If no scaling activities in the specified scaling group are in progress, the operation can trigger scaling activities even before the cooldown time expires.

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 by using the value of the ScalingActivityId parameter in the response.

If the sum of the number of instances that you want to add and the number of existing instances in the scaling group is greater than the value of the MaxSize parameter, the call fails.

Instances that are manually added by calling the AttachInstances operation are not associated with the active scaling configuration of the scaling group.

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

Request parameters

ParameterTypeRequiredDescriptionExample
ScalingGroupIdstringYes

The ID of the scaling group.

asg-bp18p2yfxow2dloq****
EntrustedbooleanNo

Specifies whether the scaling group manages the lifecycles of instances that are manually added to the scaling group. Valid values:

  • true: The scaling group manages the lifecycles of instances that are manually added in a similar manner in which the scaling group manages the lifecycles of automatically created instances. After Auto Scaling removes instances from the scaling group, Auto Scaling releases the instances. After you call the DetachInstances operation to remove instances from the scaling group, Auto Scaling does not release the instances.
  • false: The scaling group does not manage the lifecycles of instances that are manually added. After Auto Scaling removes instances from the scaling group, Auto Scaling does not release the instances.
Note You cannot specify this parameter for subscription instances.

Default value: false.

false
InstanceIdsarrayNo

The IDs of the ECS instances or elastic container instances that you want to add.

stringNo

The IDs of the ECS instances or elastic container instances that you want to add. You can specify 1 to 20 instance IDs.

Examples:

  • The ID of the ECS instance that you want to add is i-28wt4****.
  • The ID of the elastic container instance that you want to add is eci-bp17gw49eu09yiwm****.
i-28wt4****
LoadBalancerWeightsarrayNo

The weights of the ECS instances or elastic container instances as the backend servers of the associated Classic Load Balancer (CLB) instance.

integerNo

The weights of the ECS instances or elastic container instances as the backend servers of the associated CLB instance. Valid values: 1 to 100. Default value: 50.

50
LifecycleHookbooleanNo

Specifies whether to trigger a lifecycle hook for a scale-out activity. Valid values:

  • true
  • false

Default value: false.

false
RegionIdstringNo

The region ID of the scaling group.

cn-qingdao

Response parameters

ParameterTypeDescriptionExample
object
ScalingActivityIdstring

The ID of the scaling activity.

asa-bp1crxor24s28xf1****
RequestIdstring

The ID of the request.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Examples

Sample success responses

JSONformat

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