All Products
Search
Document Center

Auto Scaling:EnableScalingGroup

Last Updated:Jun 03, 2024

Enables a scaling group. If a scaling group is in the Disabled state and contains an instance configuration source such as a launch template or a scaling configuration, you can call the EnableScalingGroup operation to enable the scaling group. This operation permits Auto Scaling to dynamically adjust the computing power (also known as the number of instances) in the scaling group based on your business requirements.

Usage notes

  • You can call this operation to enable a scaling group only if the scaling group is in the Inactive state and contains an instance configuration source such as a launch temple or a scaling configuration. The instance configuration source can also be the Elastic Compute Service (ECS) instance that you specified when you created the scaling group. If the preceding requirements are not met, the operation will fail.

    Note

    A scaling group can have only one active instance configuration source at a time. When you call this operation to enable a scaling group, you can specify a scaling configuration or a launch template for the scaling group. If the scaling group already have an instance configuration defined prior to your calling, the scaling configuration or launch template specified within your request will supersede the existing scaling configuration or launch template.

  • If you specify InstanceId.N to add to the scaling group within your request, Auto Scaling will check whether the addition of InstanceId.N will cause the total number of ECS instances in the scaling group to fall outside the boundaries specified by MinSize and MaxSize after you call this operation.

    • If the call results in the total number of ECS instances dropping below the value of MinSize, Auto Scaling proactively creates pay-as-you-go ECS instances to ensure that the total number reaches the minimum threshold.

      For example, if you set MinSize to 5 when you created a scaling group and include InstanceId.N within your request to add two ECS instances when you attempt to enable the scaling group, Auto Scaling creates three more ECS instances in the scaling group after the two ECS instances are added.

    • If the call results in the total number of ECS instances exceeding the value of MaxSize, the operation 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 that you want to enable in the scaling group.

LaunchTemplateId

String

No

lt-m5e3ofjr1zn1aw7****

The ID of the launch template that you want to enable in the scaling group.

LaunchTemplateVersion

String

No

Default

The version number of the launch template. Valid values:

  • A fixed template version number.

  • Default: the default template version.

  • Latest: the latest template version.

InstanceId.N

String

No

i-283vv****

The ID of ECS instance N that you want to add to the scaling group after the scaling group is enabled. Valid values of N: 1 to 20.

ECS instance N that you want to add to the scaling group must meet the following requirements:

  • ECS instance N resides in the same region as the scaling group.

  • ECS instance N is in the Running state.

  • ECS instance N is independent of any other scaling groups.

  • ECS instance N is billed on a subscription or pay-as-you-go basis, or ECS instance N is a preemptible instance.

  • If you specified VswitchID for the scaling group, ECS instance N uses the same virtual private cloud (VPC) as the scaling group.

  • If you did not specify VswitchID for the scaling group, ECS instance N uses the classic network.

LoadBalancerWeight.N

Integer

No

50

The weight of ECS instance N or elastic container instance N as a backend server. Valid values of N: 1 to 20. Valid values of this parameter: 1 to 100.

Default value: 50.

LaunchTemplateOverride.N.InstanceType

String

No

ecs.c5.xlarge

Instance type N. If you want to scale instances in the scaling group based on the weights of instance types, you must specify LaunchTemplateOverride.N.InstanceType and LaunchTemplateOverride.N.WeightedCapacity.

Instance type N specified by this parameter overwrites the instance type specified in the launch template. You can specify N instance types by using the Extend Instance Type of Launch Template feature. Valid values of N: 1 to 10.

Note

This parameter takes effect only if you specify LaunchTemplateId.

For information about the valid values of InstanceType in InstanceTypeOverride.N.InstanceType, see Overview of instance families.

LaunchTemplateOverride.N.WeightedCapacity

Integer

No

4

The weight of instance type N. The weight specifies the capacity of an instance of instance type N in the scaling group. If you want to scale instances in the scaling group based on the weights of instance type N, you must specify this parameter after you specify LaunchTemplateOverride.N.InstanceType. The values of N in the two parameters must be the same.

A higher weight specifies that a smaller number of instances of instance type N is required to meet the expected capacity requirement.

Performance metrics such as the number of vCPUs and the memory size of each instance type may vary. You can specify different weights for different instance types based on your business requirements.

Example:

  • Current capacity: 0

  • Expected number: 6

  • Capacity of ecs.c5.xlarge: 4

To meet the expected capacity requirement, Auto Scaling must scale out two ecs.c5.xlarge instances.

Note

The capacity of the scaling group during a scale-out cannot exceed the sum of the maximum number of instances that is specified by MaxSize and the maximum instance type weight.

Valid values of WeightedCapacity in InstanceTypeOverride.N.WeightedCapacity: 1 to 500.

RegionId

String

No

cn-qingdao

The region ID of the scaling group.

Response parameters

Parameter

Type

Example

Description

RequestId

String

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

The request ID.

Examples

Sample requests

http(s)://ess.aliyuncs.com/?Action=EnableScalingGroup
&ScalingGroupId=asg-bp14wlu85wrpchm0****
&ActiveScalingConfigurationId=asc-bp1ffogfdauy0nu5****
&LaunchTemplateId=lt-m5e3ofjr1zn1aw7****
&LaunchTemplateVersion=Default
&InstanceId=["i-283vv****"]
&LoadBalancerWeight=[50]
&LaunchTemplateOverride=[{"InstanceType":"ecs.c5.xlarge","WeightedCapacity":4}]
&RegionId=cn-qingdao
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

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

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

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

Error codes

For a list of error codes, see Service error codes.

HTTP status code

Error code

Error message

Description

404

InvalidScalingGroupId.NotFound

The specified scaling group does not exist.

The specified scaling group does not exist in the current Alibaba Cloud account.

403

Forbidden.Unauthorized

A required authorization for the specified action is not supplied.

Auto Scaling is not authorized to call the operation.

400

IncorrectScalingGroupStatus

The current status of the specified scaling group does not support this action.

The specified scaling group is in the Deleting state.

404

InvalidScalingConfigurationId.NotFound

The specified scaling configuration does not exist.

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 instance type in the specified scaling configuration is different from the instance type in the active scaling configuration.

400

MissingActiveScalingConfiguration

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

No active scaling configuration is specified for the scaling group.

404

InvalidInstanceId.NotFound

Instance "XXX" does not exist.

The specified ECS instance does not exist in the current Alibaba Cloud account.

400

InvalidInstanceId. RegionMismatch

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

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 instance type of the specified ECS instance is different from the instance type that is specified in the active scaling configuration.

400

IncorrectInstanceStatus

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

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 network type of the specified ECS instance does not match the network type of the scaling group.

400

InvalidInstanceId.VPCMismatch

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

The specified scaling group and the added ECS instance are not in the same VPC.

400

InvalidInstanceId.InUse

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

The specified ECS instance has been added to another scaling group.

400

IncorrectLoadBalancerStatus

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

The specified load balancer is not in the Active state.

400

IncorrectLoadBalancerHealthCheck

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

Health check is not enabled for the specified load balancer.

400

InvalidLoadBalancerId.IncorrectInstanceNetworkType

The network type of the instance in specified Load Balancer does not support this action.

The network type of an ECS instance that is attached to the specified load balancer is different from the network type of the scaling group.

400

InvalidLoadBalancerId.VPCMismatch

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

An ECS instance that is attached to the specified load balancer does not reside in the same VPC as the vSwitch that is specified by VSwitchId.

400

IncorrectDBInstanceStatus

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

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 addition of the specified number of ECS instances results in the total number of ECS instances in the scaling group exceeding the value of MaxSize.

400

LaunchTemplateVersionSet.NotFound

The specific version of launch template is not exist.

The specified version of the launch template does not exist.

400

LaunchTemplateSet.NotFound

The specified launch template set is not found.

The specified launch template does not exist.

400

TemplateMissingParameter.ImageId

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

No value is specified for ImageId that is required in the launch template.

400

TemplateMissingParameter.InstanceTypes

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

No value is specified for InstanceTypes that is required in the launch template.

400

TemplateMissingParameter.SecurityGroup

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

No value is specified for SecurityGroup that is required in the launch template.

400

TemplateVersion.NotNumber

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

The fixed version number that is specified for LaunchTemplateVersion contains non-digit characters.