All Products
Search
Document Center

Auto Scaling:CreateScalingGroup

更新時間:Nov 04, 2024

Creates a scaling group. You can call the CreateScalingGroup operation to automate the adjustment of computing power of a specific type based on your business requirements and scaling polices.

Usage notes

A scaling group is a group of Elastic Compute Service (ECS) instances that can be used for similar business purposes.

You can create only a limited number of scaling groups in a region. To check your quota of scaling groups, go to Quota Center.

A scaling group does not immediately take effect after it is created. You must call the EnableScalingGroup operation to enable the scaling group. After you enable a scaling group, Auto Scaling can execute scaling rules to trigger scaling operations in the scaling group.

If you want to attach Classic Load Balancer (CLB, formerly Server Load Balancer or SLB) and ApsaraDB RDS instances to a scaling group, the CLB instances, ApsaraDB RDS instances, and scaling group must reside in the same region. For more information, see Regions and zones.

If you attach a CLB instance to a scaling group, Auto Scaling automatically adds ECS instances in the scaling group to the backend server groups of the CLB instance. You can specify a server group to which you can add ECS instances. You can add ECS instances to the following types of server groups:

Note

If you specify the default server group and multiple vServer groups at the same time, ECS instances are added to all specified server groups.

  • Default server group: a group of ECS instances that are used to receive frontend requests. If you do not specify a vServer group or a primary/secondary server group for a listener, requests are forwarded to the ECS instances in the default server group.

  • vServer group: If you want to forward requests to different backend servers or configure domain name-based or URL-based routing methods, you can specify vServer groups.

The default weight of an ECS instance as a backend server of a CLB instance is 50. The CLB instance that you want to attach to a scaling group must meet the following requirements:

  • The CLB instance must be in the Active state. You can call the DescribeLoadBalancers operation to query the status of a CLB instance.

  • The health check feature must be enabled on all listener ports that are configured for the CLB instance. Otherwise, the scaling group cannot be created.

If you attach an Application Load Balancer (ALB) or Network Load Balancer (NLB) server group to a scaling group, Auto Scaling automatically adds ECS instances in the scaling group to the ALB or NLB server group to process requests distributed by the ALB or NLB instance to which the ALB or NLB server group belongs. You can specify multiple ALB or NLB server groups. However, the server groups must belong to the same virtual private cloud (VPC) as the scaling group. For more information, see AttachAlbServerGroups or AttachServerGroups.

If you attach an ApsaraDB RDS instance to a scaling group, Auto Scaling automatically adds the private IP addresses of the ECS instances that are in the scaling group to the IP address whitelist of the ApsaraDB RDS instance. The ApsaraDB RDS instance that you want to attach to a scaling group must meet the following requirements:

  • The ApsaraDB RDS instance must be in the Running state. You can call the DescribeDBInstances operation to query the status of an ApsaraDB RDS instance.

  • The number of IP addresses in the IP address whitelist of the ApsaraDB RDS instance cannot exceed the upper limit. For more information, see Configure IP address whitelists.

If you set MultiAZPolicy of the scaling group to COST_OPTIMIZED, take note of the following items:

  • You can use OnDemandBaseCapacity, OnDemandPercentageAboveBaseCapacity, and SpotInstancePools to specify the instance allocation method under the cost optimization policy. Auto Scaling prioritizes the implementation of the instance allocation method during scaling events.

  • If you do not specify OnDemandBaseCapacity, OnDemandPercentageAboveBaseCapacity, or SpotInstancePools, the instance types that have the lowest price are preferentially used to create instances based on the cost optimization policy.

If you set Tag.N.Propagate of the scaling group to true, take note of the following items:

  • The tags that you add to the scaling group cannot be propagated to existing instances in the scaling group. The tags that you add to the scaling group are propagated to only new instances.

  • If you specify instance tags in the scaling configuration that is used to create instances and propagate the tags that you add to the scaling group to the instances, all tags exist at the same time.

  • If the tag key that you specify in a scaling configuration and the tag key that you add to the scaling group that uses the scaling configuration are the same, the tag value that you specify in the scaling configuration is used.

Debugging

OpenAPI Explorer automatically generates 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

CreateScalingGroup

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

ScalingGroupName

String

No

scalinggroup****

The name of the scaling group. The name of a scaling group must be unique in a region.

The name must be 2 to 64 characters in length and can contain letters, digits, underscores (_), hyphens (-), and periods (.). It must start with a letter or a digit.

If you leave this parameter empty, the value of ScalingGroupId is used.

LaunchTemplateId

String

No

lt-m5e3ofjr1zn1aw7****

The ID of the launch template that provides instance configurations for Auto Scaling to create instances.

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

String

No

i-28wt4****

The ID of the instance from which Auto Scaling obtains the required configuration information and uses the information to automatically create a scaling configuration.

RegionId

String

Yes

cn-qingdao

The region ID of the scaling group. For more information, see Regions and zones.

MinSize

Integer

Yes

2

The minimum number of instances that must be contained in the scaling group. If the total number of instances in the scaling group is less than the value of MinSize, Auto Scaling automatically adds instances to the scaling group until the total number is equal to the minimum number.

Note

The value of MinSize must be less than or equal to the value of MaxSize.

MaxSize

Integer

Yes

20

The maximum number of instances that can be contained in the scaling group. If the total number of instances in the scaling group is greater than the value of MaxSize, Auto Scaling automatically removes instances from the scaling group until the total number is equal to the maximum number.

The value range of MaxSize varies based on the instance quota. You can go to Quota Center to check the maximum number of instances that a scaling group can contain.

For example, if a scaling group can contain up to 2,000 instances, the value range of MaxSize is 0 to 2000.

DefaultCooldown

Integer

No

300

The cooldown period of the scaling group after a scaling operation is complete. Valid values: 0 to 86400. Unit: seconds.

During the cooldown period, Auto Scaling does not execute scaling operations that are triggered by CloudMonitor event-triggered tasks.

Default value: 300.

LoadBalancerIds

String

No

["lb-bp1u7etiogg38yvwz****", "lb-bp168cqrux9ai9l7f****", "lb-bp1jv3m9zvj22ufxp****"]

The IDs of the CLB instances that you want to attach to the scaling group. The value can be a JSON array that contains multiple CLB instance IDs. Separate multiple IDs with commas (,).

You can attach only a limited number of CLB instances to a scaling group. To check the quota of CLB instances that you can attach to a scaling group, go to Quota Center.

DBInstanceIds

String

No

["rm-bp142f86de0t7****", "rm-bp18l1z42ar4o****", "rm-bp1lqr97h4aqk****"]

The IDs of the ApsaraDB RDS instances that you want to attach to the scaling group. The value can be a JSON array that contains multiple ApsaraDB RDS instance IDs. Separate multiple IDs with commas (,).

You can attach only a limited number of ApsaraDB RDS instances to a scaling group. To check the quota of ApsaraDB RDS instances that you can attach to a scaling group, go to Quota Center.

RemovalPolicy.1

String

No

OldestScalingConfiguration

The first step of the instance removal policy. You cannot set RemovalPolicy.1, RemovalPolicy.2, and RemovalPolicy.3 to the same value. Valid values:

  • OldestInstance: removes ECS instances that are added at the earliest point in time to the scaling group.

  • NewestInstance: removes ECS instances that are added at the most recent point in time to the scaling group.

  • OldestScalingConfiguration: removes ECS instances that are created based on the earliest scaling configuration.

  • CustomPolicy: removes ECS instances based on the custom scale-in policy (Function).

The scaling configuration source specified by the OldestScalingConfiguration setting can be a scaling configuration or a launch template. You can specify CustomPolicy only as the value of RemovalPolicy.1. If you set RemovalPolicy.1 to CustomPolicy, you must also specify CustomPolicyARN.

Note

The value of MultiAZPolicy also affects the removal of ECS instances from a scaling group. For more information, see Configure a combination policy for removing instances.

RemovalPolicy.2

String

No

OldestInstance

The second step of the instance removal policy. You cannot set RemovalPolicy.1, RemovalPolicy.2, and RemovalPolicy.3 to the same value. Valid values:

  • OldestInstance: removes ECS instances that are added at the earliest point in time to the scaling group.

  • NewestInstance: removes ECS instances that are added at the most recent point in time to the scaling group.

  • OldestScalingConfiguration: removes ECS instances that are created based on the earliest scaling configuration.

Note

The value of MultiAZPolicy also affects the removal of ECS instances from a scaling group. For more information, see Configure a combination policy for removing instances.

RemovalPolicy.3

String

No

NewestInstance

The third step of the instance removal policy. You cannot set RemovalPolicy.1, RemovalPolicy.2, and RemovalPolicy.3 to the same value. Valid values:

  • OldestInstance: removes ECS instances that are added at the earliest point in time to the scaling group.

  • NewestInstance: removes ECS instances that are added at the most recent point in time to the scaling group.

  • OldestScalingConfiguration: removes ECS instances that are created based on the earliest scaling configuration.

Note

The value of MultiAZPolicy also affects the removal of ECS instances from a scaling group. For more information, see Configure a combination policy for removing instances.

VSwitchId

String

No

vsw-bp14zolna43z266bq****

The ID of the vSwitch. If you specify VSwitchId, the network type of the scaling group is VPC.

Note

If you do not specify VSwitchId or VSwitchIds.N, the network type of the scaling group is classic network.

MultiAZPolicy

String

No

PRIORITY

The scaling policy of the multi-zone scaling group of the ECS type. Valid values:

  • PRIORITY: Auto Scaling scales ECS instances based on the priorities of the vSwitches specified by VSwitchIds.N. Auto Scaling scales instances in the zone in which the vSwitch that has the highest priority resides. If the scaling fails, Auto Scaling scales instances in the zone in which the vSwitch that has the next highest priority resides.

  • COST_OPTIMIZED: Auto Scaling preferentially scales out ECS instances that have the lowest unit price of vCPUs and scales in ECS instances that have the highest unit price of vCPUs. If preemptible instance types are specified in the scaling configuration, Auto Scaling preferentially scales out preemptible instances. You can use CompensateWithOnDemand to specify whether to automatically create pay-as-you-go instances when preemptible instances cannot be created due to insufficient resources.

    Note

    If you specify multiple instance types or at least one preemptible instance type, COST_OPTIMIZED is valid.

  • BALANCE: Auto Scaling evenly distributes ECS instances across the zones specified for the scaling group. If ECS instances are unevenly distributed across the specified zones due to insufficient resources, you can call the RebalanceInstance operation to rebalance the distribution of the ECS instances across the zones.

  • COMPOSABLE: You can combine the preceding policies in a flexible manner to meet your business requirements. Alternatively, you can specify custom parameters to control the capacity of your scaling group in a fine-grained manner.

Default value: PRIORITY.

HealthCheckType

String

No

ECS

The health check mode of the scaling group. Valid values:

  • NONE: Auto Scaling does not check the health status of instances.

  • ECS: Auto Scaling checks the health status of instances in the scaling group. If you want to enable instance health check, you can set the value to ECS, regardless of whether the scaling group is of the ECS or Elastic Container Instance type.

  • LOAD_BALANCER: Auto Scaling checks the health status of ECS instances based on the health check results of load balancers. The health check results of CLB instances are not supported as the health check basis for instances in the scaling group.

Default value: ECS.

Note

If you want to enable instance health check and load balancer health check at the same time, we recommend that you specify HealthCheckTypes.

ScalingPolicy

String

No

recycle

The instance reclaim mode of the scaling group. Valid values:

  • recycle: the economical mode.

  • release: the release mode.

  • forcerelease: the forced release mode.

    Note

    If you set this parameter to forcerelease, Auto Scaling forcibly releases instances that are in the Running state during scale-in events. Forced release is equivalent to a power outage and may cause ephemeral data on instances to be cleared beyond recovery. Exercise caution when you specify this setting.

  • forcerecycle: the forced recycle mode.

    Note

    If you set this parameter to forcerecycle, Auto Scaling forcibly shuts down instances that are in the Running state during scale-in events. Forced shutdown is equivalent to a power outage and may cause ephemeral data on instances to be cleared beyond recovery. Exercise caution when you specify this setting.

ScalingPolicy specifies the reclaim mode of scaling groups. The policy that is used to remove ECS instances from scaling groups is specified by RemovePolicy of the RemoveInstances operation. For more information, see RemoveInstances.

ClientToken

String

No

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

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.

OnDemandBaseCapacity

Integer

No

30

The minimum number of pay-as-you-go instances that must be contained in the scaling group. Valid values: 0 to 1000. If the number of pay-as-you-go instances is less than the value of this parameter, Auto Scaling preferentially creates pay-as-you-go instances.

If you set MultiAZPolicy to COMPOSABLE, the default value of this parameter is 0.

OnDemandPercentageAboveBaseCapacity

Integer

No

20

The percentage of pay-as-you-go instances among the excess instances when the requirement on the minimum number of pay-as-you-go instances is met. Valid values: 0 to 100.

If you set MultiAZPolicy to COMPOSABLE, the default value of this parameter is 100.

SpotInstanceRemedy

Boolean

No

true

Specifies whether to enable the supplementation of preemptible instances. If you set this parameter to true, Auto Scaling creates an instance to replace a preemptible instance when Auto Scaling receives a system message which indicates that the preemptible instance will be reclaimed.

CompensateWithOnDemand

Boolean

No

true

Specifies whether to automatically create pay-as-you-go instances to meet the requirement on the number of ECS instances when the expected capacity of preemptible instances cannot be provided due to reasons such as cost-related issues and insufficient resources. This parameter is supported only if you set MultiAZPolicy to COST_OPTIMIZED. Valid values:

  • true

  • false

Default value: true.

SpotInstancePools

Integer

No

5

The number of instance types that you want to specify. Auto Scaling evenly creates preemptible instances of multiple instance types that have the lowest price in the scaling group. Valid values: 1 to 10.

If you set MultiAZPolicy to COMPOSABLE, the default value of this parameter is 2.

DesiredCapacity

Integer

No

5

The expected number of ECS instances in the scaling group. Auto Scaling maintains the expected number of ECS instances in the scaling group. The expected number cannot be greater than the value of MaxSize and cannot be less than the value of MinSize.

GroupDeletionProtection

Boolean

No

true

Specifies whether to enable the Deletion Protection feature for the scaling group. Valid values:

  • true: enables the Deletion Protection feature for the scaling group. The scaling group cannot be deleted.

  • false: disables the Deletion Protection feature for the scaling group.

Default value: false.

GroupType

String

No

ECS

The type of instances in the scaling group. Valid values:

  • ECS: ECS instances.

  • ECI: elastic container instances.

Default value: ECS.

ContainerGroupId

String

No

eci-uf6fonnghi50u374****

The ID of the elastic container instance.

VSwitchIds.N

String

No

vsw-bp14zolna43z266bq****

The IDs of the vSwitches. If you specify VSwitchIds.N, VSwitchId is ignored. If you specify VSwitchIds.N, the network type of the scaling group is VPC.

If you specify multiple vSwitches, the following rules take effect:

  • The vSwitches must belong to the same VPC.

  • The vSwitches can belong to different zones.

  • The vSwitches are sorted in ascending order based on their priorities. The first vSwitch that is specified by VSwitchIds.N has the highest priority. When ECS instances cannot be created in the zone in which the vSwitch that has the highest priority resides, Auto Scaling creates instances in the zone in which the vSwitch that has the next highest priority resides.

Note

If you do not specify VSwitchId or VSwitchIds.N, the network type of the scaling group is classic network.

LifecycleHook.N.DefaultResult

String

No

CONTINUE

The action that the scaling group performs when the lifecycle hook times out. Valid values:

  • CONTINUE: Auto Scaling continues to respond to scaling requests.

  • ABANDON: Auto Scaling releases ECS instances that are created during scale-out events, or removes ECS instances from the scaling group during scale-in events.

If multiple lifecycle hooks in the scaling group are triggered during a scale-in event, and you set DefaultResult to ABANDON for one of the lifecycle hooks, Auto Scaling immediately performs the action after the lifecycle hook whose DefaultResult is set to ABANDON times out. In this case, other lifecycle hooks time out ahead of schedule. In other cases, Auto Scaling performs the action only after all lifecycle hooks time out. The action that Auto Scaling performs is determined by the value of DefaultResult that you set for the lifecycle hook that most recently times out.

Default value: CONTINUE.

LifecycleHook.N.LifecycleHookName

String

No

lifecyclehook****

The name of the lifecycle hook. After you specify this parameter, you cannot change the name of the lifecycle hook. If you do not specify this parameter, the name of the lifecycle hook is the same as the ID of the lifecycle hook.

LifecycleHook.N.LifecycleTransition

String

No

SCALE_OUT

The type of scaling event to which you want to apply the lifecycle hook. Valid values:

  • SCALE_OUT

  • SCALE_IN

Note

If you create lifecycle hooks in the scaling group, you must specify LifecycleHook.N.LifecycleTransition.

LifecycleHook.N.NotificationMetadata

String

No

Test

The fixed string that you want to include in notifications. When the lifecycle hook takes effect, Auto Scaling sends notifications. The fixed string cannot exceed 128 characters in length. Auto Scaling sends the value of NotificationMetadata together with the notification. This allows you to categorize and manage notifications in an efficient manner. If you specify NotificationMetadata, you must specify NotificationArn.

LifecycleHook.N.NotificationArn

String

No

acs:ess:cn-hangzhou:1111111111:queue/queue2

The Alibaba Cloud Resource Name (ARN) of the notification method that Auto Scaling uses to send notifications when a lifecycle hook takes effect. This method can be a Simple Message Queue (SMQ, formerly MNS) queue or topic. Specify the value in the following format: acs:ess:{region}:{account-id}:{resource-relative-id}.

  • region: the region ID of the scaling group.

  • account-id: the ID of the Alibaba Cloud account.

Examples:

  • MNS queue: acs:ess:{region}:{account-id}:queue/{queuename}

  • MNS topic: acs:ess:{region}:{account-id}:topic/{topicname}

LifecycleHook.N.HeartbeatTimeout

Integer

No

600

The period of time before the lifecycle hook times out. After the lifecycle hook times out, Auto Scaling performs the default action. Valid values: 30 to 21600. Unit: seconds.

After you create a lifecycle hook, you can call the RecordLifecycleActionHeartbeat operation to extend the timeout period of the lifecycle hook. You can also call the CompleteLifecycleAction operation to end the timeout period ahead of schedule.

Default value: 600.

VServerGroup.N.VServerGroupAttribute.N.VServerGroupId

String

No

rsp-bp1443g77****

The ID of the vServer group.

For more information, see AttachVServerGroups.

VServerGroup.N.VServerGroupAttribute.N.Weight

Integer

No

100

The weight of each ECS instance as a backend server in the vServer group. If you increase the weight of a server, the number of requests that are forwarded to the server also increases. If you set the weight of a server to 0, no requests are forwarded to the server. Valid values: 0 to 100. Default value: 50.

For more information, see AttachVServerGroups.

VServerGroup.N.VServerGroupAttribute.N.Port

Integer

No

22

The port number used by each ECS instance as a backend server in the vServer group. Valid values: 1 to 65535.

For more information, see AttachVServerGroups.

VServerGroup.N.LoadBalancerId

String

No

lb-bp1u7etiogg38yvwz****

The ID of the CLB instance to which the vServer group belongs.

For more information, see AttachVServerGroups.

Tag.N.Key

String

No

Department

The key of tag N.

Tag.N.Value

String

No

Finance

The value of tag N.

Tag.N.Propagate

Boolean

No

false

Specifies whether to propagate tag N. Valid values:

  • true: propagates tag N to instances that are newly created and does not propagate tag N to instances that are already running in the scaling group.

  • false: does not propagate tag N to instances.

Default value: false.

LaunchTemplateOverride.N.InstanceType

String

No

ecs.c5.xlarge

Instance type N. The instance type that is specified by this parameter overwrites the instance type that is specified in the launch template. If you want to scale instances in the scaling group based on the weighted capacity of instances, you must specify LaunchTemplateOverride.N.InstanceType and LaunchTemplateOverride.N.WeightedCapacity.

You can specify N instance types by using the Extend 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 of an instance type specifies the capacity of a single instance of instance type N in the scaling group. If you want to scale instances in the scaling group based on the weighted capacity of instances, 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 the specified instance type is required to achieve the expected capacity.

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 achieve the expected capacity, Auto Scaling must scale out two ecs.c5.xlarge instances.

Note

The total capacity of the scaling group cannot exceed the sum of the maximum group size defined by MaxSize and the highest weight assigned to an instance type.

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

LaunchTemplateOverride.N.SpotPriceLimit

Float

No

0.025

The maximum bid price of instance type N that is specified by LaunchTemplateOverride.N.InstanceType. You can specify N instance types by using the Extend Launch Template feature. Valid values of N: 1 to 10.

Note

This parameter takes effect only if you specify LaunchTemplateId.

AlbServerGroup.N.AlbServerGroupId

String

No

sgp-ddwb0y0g6y9bjm****

The ID of ALB server group N.

N indicates the serial number of the ALB server group. You can attach only a limited number of ALB server groups to a scaling group. To view the available quota or manually request a quota increase, go to Quota Center.

AlbServerGroup.N.Weight

Integer

No

100

The weight of each ECS instance as a backend server in ALB server group N. If you increase the weight of a server, the number of requests that are forwarded to the server also increases. If you set the weight of a server to 0, no requests are forwarded to the server. Valid values: 0 to 100.

N specifies the serial number of the ALB server group.

AlbServerGroup.N.Port

Integer

No

22

The port number used by each ECS instance as a backend server in ALB server group N. Valid values: 1 to 65535.

N specifies the serial number of the ALB server group.

Note

If the N values are the same but the port numbers are different, Auto Scaling associates multiple ports of ALB server group N with the scaling group.

ServerGroup.N.ServerGroupId

String

No

sgp-5yc3bd9lfyh*****

The ID of server group N.

ServerGroup.N.Type

String

No

ALB

The type of server group N. Valid values:

  • ALB: ALB server groups.

  • NLB: NLB server groups.

ServerGroup.N.Weight

Integer

No

100

The weight of each ECS instance as a backend server in server group N. Valid values: 0 to 100.

If you increase the weight of a server, the number of requests that are forwarded to the server also increases. If you set the weight of a server to 0, no requests are forwarded to the server.

ServerGroup.N.Port

Integer

No

22

The port number used by each ECS instance as a backend server in server group N. Valid values: 1 to 65535.

AzBalance

Boolean

No

false

Specifies whether to evenly distribute ECS instances in the scaling group across multiple zones. This parameter takes effect only if you set MultiAZPolicy to COMPOSABLE. Valid values:

  • true

  • false

Default value: false.

AllocationStrategy

String

No

priority

The allocation policy of instances. Auto Scaling selects instance types based on the allocation policy to create instances. The policy can be applied to pay-as-you-go and preemptible instances. This parameter takes effect only if you set MultiAZPolicy to COMPOSABLE. Valid values:

  • priority: Auto Scaling selects instance types based on the specified order of the instance types to create the required number of instances.

  • lowestPrice: Auto Scaling selects instance types that have the lowest unit price of vCPU to create the required number of instances.

Default value: priority.

SpotAllocationStrategy

String

No

lowestPrice

The allocation policy of preemptible instances. You can use this parameter to specify the allocation policy for preemptible instances. This parameter takes effect only if you set MultiAZPolicy to COMPOSABLE. Valid values:

  • priority: Auto Scaling selects instance types based on the specified order of the instance types to create the required number of preemptible instances.

  • lowestPrice: Auto Scaling selects instance types that have the lowest unit price of vCPU to create the required number of preemptible instances.

Default value: priority.

MaxInstanceLifetime

Integer

No

null

The maximum life span of each instance in the scaling group. Unit: seconds.

Valid values: 86400 to the value of Integer.maxValue.

Default value: null.

Note

This parameter is unavailable for scaling groups of the Elastic Container Instance type or scaling groups whose ScalingPolicy is set to recycle.

CustomPolicyARN

String

No

acs:fc:cn-zhangjiakou:16145688****:services/ess_custom_terminate_policy.LATEST/functions/ess_custom_terminate_policy_name

The ARN of the custom scale-in policy (Function). This parameter takes effect only if you specify CustomPolicy as the value of RemovalPolicy.1.

ResourceGroupId

String

No

rg-123****

The ID of the resource group to which you want to add the scaling group.

Note

If you specify this parameter, new scaling groups are added to the specified resource group. If you do not specify this parameter, new scaling groups are added to the default resource group.

LoadBalancerConfig.N.LoadBalancerId

String

No

147b46d767c-cn-qingdao-cm5****

The ID of the CLB instance.

LoadBalancerConfig.N.Weight

Integer

No

10

The weight of each ECS instance as a backend server in the CLB server group. If you increase the weight of a server, the number of requests that are forwarded to the server also increases. If you set the weight of a server to 0, no requests are forwarded to the server.

Valid values: 0 to 100.

HealthCheckTypes.N

String

No

ECS

The health check mode of the scaling group. Valid values:

  • NONE: Auto Scaling does not check the health status of instances.

  • ECS: Auto Scaling checks the health status of instances in the scaling group. If you want to enable instance health check, you can set the value to ECS, regardless of whether the scaling group is of the ECS or Elastic Container Instance type.

  • LOAD_BALANCER: Auto Scaling checks the health status of ECS instances based on the health check results of load balancers. The health check results of CLB instances are not supported as the health check basis for instances in the scaling group.

Default value: ECS.

DBInstance.N.DBInstanceId

String

No

rm-m5eqju85s45mu0***

The ID of the database.

DBInstance.N.Type

String

No

RDS

The type of the database. Valid values:

  • RDS: ApsaraDB RDS instances.

  • Redis: ApsaraDB for Redis instances.

  • MongoDB: ApsaraDB for MongoDB instances.

Default value: RDS.

DBInstance.N.AttachMode

String

No

SecurityIp

The method that you want to use to associate the database with the scaling group. Valid values:

  • SecurityIp: Auto Scaling adds the private IP addresses of the scaled out instances to the IP address whitelist of the database. This setting is supported only if you set DBInstance.N.Type to RDS.

  • SecurityGroup: Auto Scaling adds the security group of the applied scaling configuration to the security group whitelist of the database. This setting allows instances created from the scaling configuration to access the database.

StopInstanceTimeout

Integer

No

60

The period of time that is required by an ECS instance to enter the Stopped state during the scale-in process. Unit: seconds.

Valid values: 30 to 240.

Note
  • This parameter takes effect only if you set ScalingPolicy to release.

  • If you specify this parameter, the system proceeds with the scale-in process only after the period of time specified by StopInstanceTimeout ends. In this case, the scale-in operation continues regardless of whether the ECS instance enters the Stopped state.

  • If you do not specify this parameter, the system proceeds with the scale-in process only after the ECS instance enters the Stopped state. If the ECS instance fails to enter the Stopped state, the scale-in process rolls back, and the scale-in operation is considered as failed.

Response parameters

Parameter

Type

Example

Description

RequestId

String

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

The ID of the request.

ScalingGroupId

String

asg-bp14wlu85wrpchm0****

The ID of the scaling group.

Examples

Sample requests

http(s)://ess.aliyuncs.com/?Action=CreateScalingGroup
&ScalingGroupName=scalinggroup****
&LaunchTemplateId=lt-m5e3ofjr1zn1aw7****
&LaunchTemplateVersion=Default
&InstanceId=i-28wt4****
&RegionId=cn-qingdao
&MinSize=2
&MaxSize=20
&DefaultCooldown=300
&LoadBalancerIds=["lb-bp1u7etiogg38yvwz****", "lb-bp168cqrux9ai9l7f****", "lb-bp1jv3m9zvj22ufxp****"]
&DBInstanceIds=["rm-bp142f86de0t7****", "rm-bp18l1z42ar4o****", "rm-bp1lqr97h4aqk****"]
&RemovalPolicy.1=OldestScalingConfiguration
&RemovalPolicy.2=OldestInstance
&RemovalPolicy.3=NewestInstance
&VSwitchId=vsw-bp14zolna43z266bq****
&MultiAZPolicy=PRIORITY
&HealthCheckType=ECS
&ScalingPolicy=recycle
&ClientToken=123e4567-e89b-12d3-a456-42665544****
&OnDemandBaseCapacity=30
&OnDemandPercentageAboveBaseCapacity=20
&SpotInstanceRemedy=true
&CompensateWithOnDemand=true
&SpotInstancePools=5
&DesiredCapacity=5
&GroupDeletionProtection=true
&GroupType=ECS
&ContainerGroupId=eci-uf6fonnghi50u374****
&VSwitchIds=["vsw-bp14zolna43z266bq****"]
&LifecycleHook=[{"DefaultResult":"CONTINUE","LifecycleHookName":"lifecyclehook****","LifecycleTransition":"SCALE_OUT","NotificationMetadata":"Test","NotificationArn":"acs:ess:cn-hangzhou:1111111111:queue/queue2","HeartbeatTimeout":600}]
&VServerGroup=[{"VServerGroupAttribute":[{"VServerGroupId":"rsp-bp1443g77****","Weight":100,"Port":22}],"LoadBalancerId":"lb-bp1u7etiogg38yvwz****"}]
&Tag=[{"Key":"Department","Value":"Finance","Propagate":false}]
&LaunchTemplateOverride=[{"InstanceType":"ecs.c5.xlarge","WeightedCapacity":4,"SpotPriceLimit":0.025}]
&AlbServerGroup=[{"AlbServerGroupId":"sgp-ddwb0y0g6y9bjm****","Weight":100,"Port":22}]
&ServerGroup=[{"ServerGroupId":"sgp-5yc3bd9lfyh*****","Type":"ALB","Weight":100,"Port":22}]
&AzBalance=false
&AllocationStrategy=priority
&SpotAllocationStrategy=lowestPrice
&CustomPolicyARN=acs:fc:cn-zhangjiakou:16145688****:services/ess_custom_terminate_policy.LATEST/functions/ess_custom_terminate_policy_name
&ResourceGroupId=rg-123****
&LoadBalancerConfig=[{"LoadBalancerId":"147b46d767c-cn-qingdao-cm5****","Weight":10}]
&HealthCheckTypes=["ECS"]
&DBInstance=[{"DBInstanceId":"rm-m5eqju85s45mu0***","Type":"RDS","AttachMode":"SecurityIp"}]
&<Common request parameters>

Sample success responses

XML format

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

<CreateScalingGroupResponse>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
    <ScalingGroupId>asg-bp14wlu85wrpchm0****</ScalingGroupId>
</CreateScalingGroupResponse>

JSON format

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

{
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "ScalingGroupId" : "asg-bp14wlu85wrpchm0****"
}

Error codes

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

HTTP status code

Error code

Error message

Description

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

IncorrectLoadBalancerHealthCheck

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

The health check feature is not enabled for the specified CLB instance.

400

IncorrectLoadBalancerStatus

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

The specified CLB instance is not in the Active state.

400

IncorrectVSwitchStatus

The current status of virtual switch does not support this operation.

The vSwitch is unavailable. In this case, ECS instances cannot be created.

400

InvalidDBInstanceId. RegionMismatch

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

The specified ApsaraDB RDS instance and the scaling group do not reside in the same region.

400

InvalidLoadBalancerId.IncorrectAddressType

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

The network type of the specified CLB instance is different from the network type of the vSwitch.

400

InvalidLoadBalancerId.IncorrectInstanceNetworkType

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

The network type of a backend server of the specified CLB instance is different from the network type of the scaling group.

400

InvalidLoadBalancerId.RegionMismatch

The specified Load Balancer and the specified scaling group are not in the same Region.

The specified CLB instance and the scaling group do not reside in the same region.

400

InvalidLoadBalancerId.VPCMismatch

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

The vSwitch and a backend server of the specified CLB instance do not reside in the same VPC.

400

InvalidParameter

The specified value of parameter "ScalingPolicy" is not valid.

The value of ScalingPolicy is invalid.

400

InvalidParameter.Conflict

The value of parameter &lt;parameter name&gt; and parameter &lt;parameter name&gt; are conflict.

The value of MinSize is greater than the value of MaxSize.

400

InvalidScalingGroupName.Duplicate

The specified value of parameter &lt;parameter name&gt; is duplicated.

The specified scaling group name already exists.

400

QuotaExceeded.DBInstanceSecurityIP

Security IP quota exceeded in DB instance "XXX".

The maximum number of IP addresses in the IP address whitelist of the specified ApsaraDB RDS instance has been reached.

400

QuotaExceeded.PrivateIpAddress

Private IP address quota exceeded in the specified virtual switch.

No more private IP addresses are available in the CIDR block of the specified vSwitch.

400

QuotaExceeded.ScalingGroup

Scaling group quota exceeded.

The maximum number of scaling groups has been reached.

400

QuotaExceeded.VPCInstance

Instance quota exceeded in the specified VPC.

The maximum number of instances in the VPC has been reached.

404

InvalidDBInstanceId.NotFound

DB instance "XXX" does not exist.

The specified ApsaraDB RDS instance does not exist.

404

InvalidLoadBalancerId.NotFound

The specified Load Balancer does not exist.

The specified CLB instance does not exist.

404

InvalidRegionId.NotFound

The specified region does not exist.

The specified region does not exist.

404

InvalidVSwitchId.NotFound

The specified virtual switch does not exist.

The specified vSwitch does not exist.

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, which 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, which 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, which 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.

400

AlbServerGroup.NotExist

The ServerGroup "%s" do(es) not exist.

The specified ALB server group does not exist within the Alibaba Cloud account.