Enables a scaling group.

Description

You can call this operation on a scaling group only when the scaling group is in the Inactive state and has the instance configuration source configured. Instance configuration sources include scaling configurations, launch templates, and Elastic Compute Service (ECS) instances specified when scaling groups are created. Otherwise, the call fails.

Note A scaling group can have only one active instance configuration source at a time. When you call this operation on a scaling group, you can specify a scaling configuration or a launch template for the scaling group. If you have configured the instance configuration source for the scaling group before you call this operation, the specified scaling configuration or launch template in the request overwrites the original one.

After you use the InstanceId.N parameter to specify ECS instances to be added to a scaling group when you call this operation, Auto Scaling determines whether the TotalCapactiy value is between the MinSize value and the MaxSize value after the specified instances are added to the scaling group:

  • If the TotalCapactiy value is less than the MinSize value, Auto Scaling automatically creates pay-as-you-go ECS instances based on the difference between the Total Capactiy value and the MinSize value. For example, you create a scaling group whose MinSize is set to 5. You use the InstanceId.N parameter to specify two existing ECS instances when you enable the scaling group. Then, Auto Scaling automatically creates three ECS instances after the two ECS instances are added to the scaling group.
  • If the TotalCapactiy value is greater than the MaxSize value, the call fails.

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 EnableScalingGroup

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

ScalingGroupId String Yes asg-bp14wlu85wrpchm0****

The ID of the scaling group.

ActiveScalingConfigurationId String No asc-bp1ffogfdauy0nu5****

The ID of the scaling configuration to be enabled in the scaling group.

InstanceId.N RepeatList No i-283vv****

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

The ECS instances to be added to the scaling group must meet the following requirements:

  • The instances are located in the same region as the scaling group.
  • The instances are 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, 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, VPC-type ECS instances cannot be added to the scaling group.
LoadBalancerWeight.N RepeatList No 50

The weight of ECS instance N that acts as a backend server of the associated SLB instance. Valid values of N: 1 to 20. Valid values of this parameter: 1 to 100.

Default value: 50.

LaunchTemplateId String No lt-m5e3ofjr1zn1aw7****

The ID of the launch template that is used by Auto Scaling to create ECS instances.

LaunchTemplateVersion String No Default

The version number of the launch template. Valid values:

  • A fixed template version number.
  • Default: The default template version is always used.
  • Latest: The latest template version is always used.
LaunchTemplateOverride.N.InstanceType String No ecs.c5.xlarge

If you want to scale the scaling group based on the capacity, you must specify both the LaunchTemplateOverride.N.InstanceType and LaunchTemplateOverride.N.WeightedCapacity parameters.

This parameter specifies instance type N to override the instance types specified in the launch template. You can specify N values for this parameter and N instance types for the extended configurations. Valid values of N: 1 to 10.

Note This parameter is valid only when the LaunchTemplateId parameter is specified.

Valid values of InstanceType: For information about available ECS instance types, see Instance families.

LaunchTemplateOverride.N.WeightedCapacity Integer No 4

If you want to scale the scaling group based on the capacity, you must specify LaunchTemplateOverride.N.WeightedCapacity after LaunchTemplateOverride.N.InstanceType is specified. The two parameters have a one-to-one correspondence between them. The N value must be the same.

This parameter specifies the weight of the instance type, which indicates the capacity of a single instance of the specified instance type in the scaling group. A greater weight indicates that a less number of instances of the specified instance type is required to meet the expected capacity.

The performance metrics such as the number of vCPUs and the memory size of each instance type may vary. You can configure different weights for different instance types to meet your requirements.

Example:

  • Current capacity: 0
  • Expected capacity: 6
  • Capacity of ecs.c5.xlarge: 4

To meet the expected capacity, Auto Scaling creates two ecs.c5.xlarge instances.

Note The capacity of the scaling group cannot exceed the sum of the maximum capacity (MaxSize) and the maximum weight of the instance type.

Valid values: 1 to 500.

Response parameters

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

The ID of the request.

Examples

Sample requests

https://ess.aliyuncs.com/?Action=EnableScalingGroup
&ScalingGroupId=asg-bp1ffogfdauy0jw0****
&InstanceId.1=i-283vv****
&<Common request parameters>

Sample success responses

XML format

<EnableScalingGroupResponse>
      <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
</EnableScalingGroupResponse>

JSON format

{
    "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

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 within 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 being deleted.

404

InvalidScalingConfigurationId.NotFound

The specified scaling configuration does not exist.

The error message returned because the specified scaling configuration does not exist in the specified scaling group.

400

InvalidScalingConfigurationId.InstanceTypeMismatch

The specified scaling configuration and existing active scaling configuration have different instance type.

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

400

MissingActiveScalingConfiguration

An active scaling configuration for the specified scaling group is not supplied.

The error message returned because no active scaling configuration is specified for the scaling group.

404

InvalidInstanceId.NotFound

Instance “XXX” does not exist.

The error message returned because the specified ECS instance does not exist within 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 configuration have different instance type.

The error message returned because the instance type of the specified ECS instance is different from that of 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

IncorrectLoadBalancerStatus

The current status of the specified load balancer does not support this action.

The error message returned because the specified SLB instance is not in the Active 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 specified SLB instance.

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 added to the specified SLB instance is different from that of the scaling group.

400

InvalidLoadBalancerId.VPCMismatch

The specified virtual switch and the instance in specified Load Balancer are not in the same VPC.

The error message returned because the ECS instance added to the specified SLB instance is not in the same VPC as the vSwitch specified by VSwitchID.

400

IncorrectDBInstanceStatus

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

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

400

IncorrectCapacity.MaxSize

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

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

400

LaunchTemplateVersionSet.NotFound

The specific version of launch template is not exist.

The error message returned because the specified version of the launch template does not exist.

400

LaunchTemplateSet.NotFound

The specified launch template set is not found.

The error message returned because the specified launch template does not exist.

400

TemplateMissingParameter.ImageId

The input parameter "ImageId" that is mandatory for processing this request is not supplied.

The error message returned because the ImageId parameter required for the specified launch template is not specified.

400

TemplateMissingParameter.InstanceTypes

The input parameter "InstanceTypes" that is mandatory for processing this request is not supplied.

The error message returned because the InstanceTypes parameter required for the specified launch template is not specified.

400

TemplateMissingParameter.SecurityGroup

The input parameter "SecurityGroup" that is mandatory for processing this request is not supplied.

The error message returned because the SecurityGroup parameter required for the specified launch template is not specified.

400

TemplateVersion.NotNumber

The input parameter "LaunchTemplateVersion" is supposed to be a string representing the version number.

The error message returned because the fixed version number specified for the LaunchTemplateVersion parameter of the launch template contains non-digit characters.