All Products
Search
Document Center

Auto Scaling:AttachInstances

Last Updated:Dec 11, 2024

Adds instances to a scaling group to provide services or restarts Elastic Compute Service (ECS) instances stopped in Economical Mode to provide services. You can call the AttachInstances operation to add ECS instances, elastic container instances, or third-party instances managed by Alibaba Cloud to your scaling group to provide services. You can also call this operation to restart ECS instances stopped in Economical Mode in your scaling group to provide services.

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

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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

Request parameters

ParameterTypeRequiredDescriptionExample
ScalingGroupIdstringYes

The ID of the scaling group.

asg-bp18p2yfxow2dloq****
EntrustedbooleanNo

Specifies whether to use the scaling group to manage the lifecycles of manually added instances. Valid values:

  • true: The scaling group manages the lifecycles of manually added instances and automatically created instances in the same manner. In this case, Auto Scaling releases the instances when they are removed from the scaling group. This rule does not apply to instances that are removed by calling the DetachInstances operation.
  • false: The scaling group does not manage the lifecycles of manually added instances. In this case, Auto Scaling does not release the instances when they are removed from the scaling group.
Note You cannot specify this parameter for subscription instances, non-Alibaba Cloud instances, and instances in Economical Mode.

Default value: false.

false
InstanceIdsarrayNo

The IDs of the ECS instances, elastic container instances, non-Alibaba Cloud instances, or instances in Economical Mode.

stringNo

The ID of the ECS instance, elastic container instance, non-Alibaba Cloud instance, or instance in Economical Mode.

Sample IDs:

  • ECS instance: i-28wt4****.
  • Elastic container instance: eci-bp17gw49eu09yiwm****.
  • Non-Alibaba Cloud instance: mi-2cx*****.
  • ECS instance in Economical Mode: i-2cd2f****.
Note You can add only instances of the same type to a scaling group at a time in each call.
i-28wt4****
LoadBalancerWeightsarrayNo

The weight of an ECS instance or elastic container instance as a backend server. You can use this parameter to specify weights for multiple instances at the same time.

integerNo

The weight of an ECS instance or elastic container instance as a backend server. Valid values: 1 to 100.

Note You cannot specify this parameter for subscription instances and instances in Economical Mode.

Default value: 50.

50
LifecycleHookbooleanNo

Specifies whether to trigger the lifecycle hook for scale-outs when you call this operation. Valid values:

  • true
  • false
Note You cannot specify this parameter for subscription instances and instances in Economical Mode.

Default value: false.

false
RegionIdstringNo

The region ID of the scaling group.

cn-qingdao
ClientTokenstringNo

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

You can use the client to generate the token, but you must 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 Ensure idempotence.

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

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