You can call this operation to add ECS instances to a scaling group.

Description

The following limits apply to the ECS instances to be added:

  • The ECS instances and the scaling group must be in the same region.
  • The ECS instances must be in the Running state.
  • The ECS instances are not added to other scaling groups.
  • The ECS instances use the subscription or pay-as-you-go billing method.
  • If the VSwitchId parameter is specified for a scaling group, ECS instances in the classic network or not in the same VPC as the specified VSwitch cannot be added to the scaling group.
  • If the VSwitchId parameter is not specified for a scaling group, ECS instances of the VPC type cannot be added to the scaling group.

This operation can be called only when the scaling group is enabled.

This operation can be called only when the scaling group does not have scaling activities in progress.

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

If the call is successful, Auto Scaling has accepted the request. However, this does not mean that the scaling activity will succeed. You can determine the status of a scaling activity based on the returned value of the ScalingActivityId parameter.

If the sum of the number of ECS instances to be added and the existing number of ECS instances in the scaling group is greater than the MaxSize value, the call fails.

Manually added ECS instances 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. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes AttachInstances

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

InstanceId.1 String Yes i-28wt4****

The ID of ECS instance N to be added. Valid values of N: 1 to 20.

ScalingGroupId String Yes asg-bp18p2yfxow2dloq****

The ID of the scaling group.

LoadBalancerWeight.1 Integer No 50

The weight of ECS instance N as an SLB backend server. Valid values of N: 1 to 20. Valid values for this parameter: 1 to 100.

Default value: 50

Entrusted Boolean No false

Specifies whether to enable Auto Scaling to manage the lifecycle of ECS instances in a scaling group when you manually add the instances to the scaling group. Valid values:

  • true: enables Auto Scaling to manage the lifecycle of the instances in the scaling group. The lifecycle of the instances is managed by Auto Scaling and is the same as that of automatically created instances. When the instances are removed from the scaling group, the instances are automatically released. When the instances are removed from the scaling group through calls to DetachInstances, they are not released.
  • false: does not enable Auto Scaling to manage the lifecycle of the instances in the scaling group. After the instances are removed from the scaling group, the instances are not released.

Default value: false

Note This feature is not applicable to subscription instances.

Response parameters

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

The ID of the request.

ScalingActivityId String asa-bp1crxor24s28xf1****

The ID of the scaling activity.

Examples

Sample requests

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

Sample success responses

XML format

<AttachInstancesResponse>
      <ScalingActivityId>asa-bp1crxor24s28xf1****</ScalingActivityId>
      <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
</AttachInstancesResponse>

JSON format

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

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 in the current account.

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 enabled.

404

InvalidInstanceId.NotFound

Instance "XXX" does not exist.

The error message returned because the specified ECS instance does not exist in the current account.

400

InvalidInstanceId. RegionMismatch

Instance "XXX" and the specified scaling group are not in the same Region.

The error message returned because the specified ECS instance and the scaling group are not in the same region.

400

InvalidInstanceId.InstanceTypeMismatch

Instance "XXX" and existing Active scaling configurations have different instance types.

The error message returned because the instance type of the specified ECS instance is different from that in the active scaling configuration.

400

IncorrectInstanceStatus

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

The error message returned because the specified ECS instance is not in the Running state.

400

InvalidInstanceId. NetworkTypeMismatch

The network type of instance "XXX" does not support this action.

The error message returned because the network type of the specified ECS instance is different from that of the scaling group.

400

InvalidInstanceId.VPCMismatch

Instance "XXX" and the specified scaling group are not in the same VPC.

The error message returned because the added ECS instance and the specified scaling group are not in the same VPC.

400

InvalidInstanceId.InUse

Instance "XXX" is already attached to another scaling group.

The error message returned because the specified ECS instance is already added to another scaling group.

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 the SLB instance associated with the specified scaling group is not in the Running state.

400

IncorrectLoadBalancerHealthCheck

The current health check type of specified load balancer does not support this action.

The error message returned because health check is not enabled for the SLB instance associated with the specified scaling group.

400

InvalidLoadBalancerId.IncorrectInstanceNetworkType

The network type of the instance in specified load balancer does not support this action.

The error message returned because the network type of the ECS instance associated with the specified SLB instance is different from that of the scaling group.

400

InvalidLoadBalancerId.VPCMismatch

he specified virtual switch and the instance in specified load balancer are not in the same VPC.

The error message returned because the ECS instance associated with an SLB instance for the specified scaling group is not in the same VPC as the VSwitch.

400

IncorrectDBInstanceStatus

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

The error message returned because the ApsaraDB for RDS instance associated with the specified scaling group is not in the Running state.

400

QuotaExceeded.DBInstanceSecurityIP

Security IP quota exceeded in DB instance "XXX".

The error message returned because the maximum number of IP addresses added to the whitelist of the ApsaraDB for RDS instance associated with the specified scaling group has been reached.

400

QuotaExceeded.SecurityGroupInstance

Instance quota exceeded in the specified security group.

The error message returned because the maximum number of ECS instances in the specified security group has been reached.

400

IncorrectCapacity.MaxSize

To attach the instances, the total capacity will be greater than the MaxSize.

The error message returned because the total number of ECS instances (Total Capacity) will exceed the specified MaxSize value after the specified ECS instances are added to the scaling group.