Attach an ECS instance

Last Updated: May 11, 2017

Description

  • Attaches an ECS instance to a specified scaling group. Restrictions on the attached ECS instance:

    • The attached ECS instance and the scaling group must be in the same region.
    • The attached ECS instance and the instance with active scaling configurations must be of the same type.
    • The attached ECS instance must in the running state.
    • The attached ECS instance has not been attached to other scaling groups.
    • The attached ECS instance supports Subscription and Pay-As-You-Go payment methods.
    • If the VswitchID is specified for a scaling group, you cannot attach Classic ECS instances or ECS instances on other VPCs to the scaling group.
    • If the VswitchID is not specified for the scaling group, ECS instances of the VPC type cannot be attached to the scaling group.
  • The interface can be called only when the scaling group is active.

  • The interface can be called only when the scaling group has no scaling activity in progress.

  • When the scaling group has no scaling activity in progress, the interface can be directly executed without cooldown.

  • Successfully calling this interface only means that the Auto Scaling service has accepted the call request, and the scaling activity can be executed, but does not necessarily mean that the scaling activity can be successfully executed. You can use the returned ScalingActivityId to check the status of the scaling activity.

  • The call attempt may fail when the total capacity of instances specified by this interface plus the instances of the scaling group is greater than MaxSize.

  • The manually attached ECS instance is not associated with the active scaling configurations of the scaling group.

Request parameters

Name Type Required? Description
Action String Yes Operation interface name, required parameter. Value: AttachInstances.
ScalingGroupId String Yes Scaling group ID.
InstanceId.N String Yes ECS instance ID. You can input up to 20 IDs.

Return parameters

Name Type Description
ScalingActivityId String Scaling activity ID

Error code

For errors common to all interfaces, refer to the Client Error Table or Server Error Table.

Error Error code Description HTTP status code
The specified scaling group does not exist in this account. InvalidScalingGroupId.NotFound The specified scaling group does not exist. 404
Open API is not fully authorized to the Auto Scaling service. Forbidden.Unauthorized A required authorization for the specified action is not supplied. 403
The specified scaling group is not active. IncorrectScalingGroupStatus The current status of the specified scaling group does not support this action. 400
The specified ECS instance does not exist in this account. InvalidInstanceId.NotFound Instance “XXX” does not exist. 404
The specified ECS instance and the scaling group are not in the same region. InvalidInstanceId. RegionMismatch Instance “XXX” and the specified scaling group are not in the same Region. 400
The specified ECS instance and the instance with valid scaling configurations do not match. InvalidInstanceId.InstanceTypeMismatch Instance “XXX” and existing active scaling configurations have different instance types. 400
The specified ECS instance is not in the running status. IncorrectInstanceStatus The current status of instance “XXX” does not support this action. 400
The specified ECS instance and the scaling group are not in the same region. InvalidInstanceId. NetworkTypeMismatch The network type of instance “XXX” does not support this action. 400
The specified scaling group and the attached ECS instance are not in the same VPC. InvalidInstanceId.VPCMismatch Instance “XXX” and the specified scaling group are not in the same VPC. 400
The specified ECS instance has been attached to another scaling group. InvalidInstanceId.InUse Instance “XXX” is already attached to another scaling group. 400
The specified scaling group has an in-progress scaling activity. 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. 400
The Server Load Balancer instance of the specified scaling group is not in the active status. IncorrectLoadBalancerStatus The current status of the specified load balancer does not support this action. 400
Health check is not enabled for the Server Load Balancer of the specified scaling group. IncorrectLoadBalancerHealthCheck The current health check type of specified load balancer does not support this action. 400
The network type of the ECS instance contained in the specified Server Load Balancer is different from the network type of the scaling group. InvalidLoadBalancerId.IncorrectInstanceNetworkType The network type of the instance in specified load balancer does not support this action. 400
The ECS instance contained in the specified Server Load Balancer and VSwitchId are not in the same VPC. InvalidLoadBalancerId.VPCMismatch The specified virtual switch and the instance in specified load balancer are not in the same VPC. 400
The RDS instance in the specified scaling group is not in the running status. IncorrectDBInstanceStatus The current status of DB instance “XXX” does not support this action. 400
The number of IP addresses in the white list that can access the RDS instance in the scaling group has exceeded the upper limit. QuotaExceeded.DBInstanceSecurityIP Security IP quota exceeded in DB instance “XXX”. 400
The number of ECS instances attached to the specified security group exceeds the upper limit. QuotaExceeded.SecurityGroupInstance Instance quota exceeded in the specified security group. 400
Total Capacity after the ECS instance is attached is greater than MaxSize. IncorrectCapacity.MaxSize To attach the instances, the total capacity will be greater than the MaxSize. 400

Example

Request example
  1. http://ess.aliyuncs.com/?Action=AttachInstances
  2. &ScalingGroupId=AG6CQdPU8OKdwLjgZcJ2eaQ
  3. &InstanceId.1=i-28wt48iaa
  4. &<Public Request Parameters>
Return example

XML format:

  1. <AttachInstancesResponse>
  2. <ScalingActivityId>bybj9OcaOT4ucPMbFhcqHfA3</ScalingActivityId>
  3. <RequestId>DD0309B7-2613-4792-9B86-275906695253</RequestId>
  4. </AttachInstancesResponse>

JSON format:

  1. "RequestId": "6469DCD0-13AC-487E-85A0-CE4922908FDE",
  2. "ScalingActivityId": "ebta5WbUzC8gcwUWvfchyT4U"
Thank you! We've received your feedback.