CreateScalingGroup

更新时间:
复制 MD 格式

Call the CreateScalingGroup API to create a scaling group. The group automatically adjusts your computing capacity (the number of instances) by scaling instances of a specified type in or out based on your business requirements and scaling policies.

Operation description

A scaling group is a collection of ECS instances for the same use case.

The number of scaling groups that you can create in a region depends on your Auto Scaling usage. To view your quota for scaling groups, go to Quota Center.

A scaling group is not active immediately after creation. You must call the EnableScalingGroup operation to enable the group before it can trigger scaling activities or execute scaling rules.

The scaling group, as well as its associated Classic Load Balancer (CLB) (formerly SLB) and RDS instances, must be in the same region. For more information, see Regions and availability zones.

If you associate a CLB instance with a scaling group, the scaling group automatically adds new ECS instances to a backend server group of the CLB instance. You can specify which server group to use. The following types of server groups are supported:

  • Default server group: A group of ECS instances that receive requests from the front end. If no vServer group or primary/standby server group is configured for a listener, it forwards requests to the ECS instances in the default server group.

  • vServer group: Use a vServer group if you need to forward different requests to different backend servers, or forward requests based on domain names and URLs.

Note

If you specify both a default server group and one or more vServer groups, the scaling group adds new ECS instances to all specified server groups.

After an instance is added to a backend server group of a CLB instance, its default weight is 50. The CLB instance must meet the following conditions:

  • The CLB instance must be in the active state. You can call the DescribeLoadBalancers operation to check the state of a CLB instance.

  • Health checks must be enabled for all listeners configured on the CLB instance. Otherwise, the scaling group creation fails.

If you associate a scaling group with Application Load Balancer (ALB), Network Load Balancer (NLB), or Gateway Load Balancer (GWLB) server groups, it automatically adds new ECS instances as backend servers to those groups to handle distributed requests. You can specify multiple such server groups, but they must all belong to the same VPC as the scaling group. For more information, see AttachAlbServerGroups or AttachServerGroups.

If you associate an RDS instance with a scaling group, the scaling group automatically adds the internal IP addresses of new ECS instances to the IP address whitelist of the RDS instance. The RDS instance must meet the following conditions:

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

  • The number of IP addresses in the RDS instance's IP address whitelist cannot exceed the limit. For more information, see the Configure an IP address whitelist topic in the RDS documentation.

If the MultiAZPolicy of a scaling group is set to COST_OPTIMIZED:

  • If you specify the OnDemandBaseCapacity, OnDemandPercentageAboveBaseCapacity, and SpotInstancePools parameters, you define the instance allocation strategy for the cost-optimized policy. Auto Scaling prioritizes this strategy during scaling activities.

  • If you do not specify the OnDemandBaseCapacity, OnDemandPercentageAboveBaseCapacity, or SpotInstancePools parameters, the cost-optimized policy creates instances by using only the lowest-cost method. In this mode, you cannot create instances by using the Elastic Guarantee service or the Capacity Reservation service.

If you enable tag propagation for a scaling group by setting Tags.Propagate to true:

  • The scaling group propagates its tags only to new instances, not to existing instances.

  • If you specify instance tags in the scaling configuration and also choose to propagate tags from the scaling group, Auto Scaling applies both sets of tags to the new instances.

  • If a tag from the scaling configuration and a propagated tag from the scaling group have the same tag key, the tag value from the scaling configuration takes precedence.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ess:CreateScalingGroup

create

*ScalingGroup

acs:ess:{#regionId}:{#accountId}:scalinggroup/*

None None

Request parameters

Parameter

Type

Required

Description

Example

ScalingGroupName

string

No

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

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

If you do not specify this parameter, the value of ScalingGroupId is used.

scalinggroup****

LaunchTemplateId

string

No

The ID of the launch template that provides the configuration for the scaling group.

lt-m5e3ofjr1zn1aw7****

LaunchTemplateVersion

string

No

The version of the launch template. Valid values:

  • A specific version number of the template.

  • Default: Uses the default version of the template.

  • Latest: Uses the latest version of the template.

Default

InstanceId

string

No

The ID of an existing instance to use as a template. Auto Scaling uses this instance to create a new scaling configuration for the scaling group.

i-28wt4****

RegionId

string

Yes

The ID of the region where the scaling group resides.

cn-qingdao

MinSize

integer

Yes

The minimum number of instances in the scaling group. If the total number of instances falls below this value, Auto Scaling adds instances to meet this minimum.

Note

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

2

MaxSize

integer

Yes

The maximum number of instances in the scaling group. If the total number of instances exceeds this value, Auto Scaling removes instances to meet this maximum.

The value range of MaxSize depends on your Auto Scaling usage. Go to Quota Center to view the quota for Maximum number of instances per scaling group.

If the quota for Maximum number of instances per scaling group is 2,000, the value of MaxSize can range from 0 to 2,000.

20

DefaultCooldown

integer

No

The cooldown period, in seconds, after a scaling activity completes. Valid values: 0 to 86400.

During the cooldown period, the scaling group does not execute other scaling activities that are triggered by CloudMonitor alarm tasks.

Default value: 300.

300

LoadBalancerIds

string

No

A JSON array of Classic Load Balancer (CLB) instance IDs.

The number of CLB instances that you can associate with a single scaling group varies based on your Auto Scaling usage. Go to Quota Center to view the quota for Maximum number of load balancer instances that can be associated with a single scaling group.

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

DBInstanceIds

string

No

A JSON array of RDS instance IDs.

The number of RDS instances that you can associate with a single scaling group varies based on your Auto Scaling usage. Go to Quota Center to view the quota for Maximum number of RDS instances that can be associated with a single scaling group.

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

RemovalPolicies

array

No

The instance removal policies. Valid values:

  • OldestInstance: Removes the ECS instance that was first added to the scaling group.

  • NewestInstance: Removes the ECS instance that was most recently added to the scaling group.

  • OldestScalingConfiguration: Removes the ECS instance that was created based on the earliest scaling configuration.

  • CustomPolicy: Removes ECS instances based on a custom scale-in policy defined by a function.

The term scaling configuration in OldestScalingConfiguration refers to the source of instance configuration information, which includes both scaling configurations and launch templates. CustomPolicy can only be set as the first removal policy. If you specify CustomPolicy, you must also specify the CustomPolicyARN parameter.

Note

The removal of instances is also affected by the scaling group's multi-AZ policy (MultiAZPolicy). For more information, see Configure a combination of removal policies.

string

No

The instance removal policies. Valid values:

  • OldestInstance: Removes the ECS instance that was first added to the scaling group.

  • NewestInstance: Removes the ECS instance that was most recently added to the scaling group.

  • OldestScalingConfiguration: Removes the ECS instance that was created based on the earliest scaling configuration.

  • CustomPolicy: Removes ECS instances based on a custom scale-in policy defined by a function.

The term scaling configuration in OldestScalingConfiguration refers to the source of instance configuration information, which includes both scaling configurations and launch templates. CustomPolicy can only be set as the first removal policy. If you specify CustomPolicy, you must also specify the CustomPolicyARN parameter.

Note

The removal of instances is also affected by the scaling group's multi-AZ policy (MultiAZPolicy). For more information, see Configure a combination of removal policies.

OldestScalingConfiguration

VSwitchId

string

No

The ID of the vSwitch. If you specify this parameter, the network type of the scaling group is Virtual Private Cloud (VPC).

Note

If you do not specify the VSwitchId or VSwitchIds parameter, the network type of the scaling group defaults to classic network.

vsw-bp14zolna43z266bq****

MultiAZPolicy

string

No

The scaling policy for ECS instances in a multi-zone scaling group. Valid values:

  • PRIORITY: Auto Scaling prioritizes the vSwitches specified in VSwitchIds. If an operation fails in a higher-priority availability zone, Auto Scaling automatically attempts it in the next-highest-priority zone.

  • COST_OPTIMIZED: During scale-out, creates instances from the instance types with the lowest vCPU unit price. During scale-in, removes instances from the instance types with the highest vCPU unit price. If the scaling configuration includes multiple spot instance types, spot instances are prioritized for creation. You can use the CompensateWithOnDemand parameter to specify whether to automatically create on-demand instances when spot instances cannot be created due to reasons such as insufficient inventory.

    Note

    The COST_OPTIMIZED policy takes effect only when the scaling configuration specifies multiple instance types or includes spot instances.

  • BALANCE: Distributes ECS instances evenly across the specified availability zones in the scaling group. If the distribution of instances becomes uneven due to insufficient inventory, you can call the RebalanceInstance API operation to rebalance the instances.

    Note

    If MultiAZPolicy is set to BALANCE, the effect is the same as setting MultiAZPolicy to COMPOSABLE and AzBalance to true.

  • COMPOSABLE: A composite policy that allows you to combine the preceding policies for multi-zone scaling groups as needed. You can also specify additional parameters to gain finer control over the capacity of your scaling group.

Default value: PRIORITY.

PRIORITY

HealthCheckType

string

No

The health check method for the scaling group. Valid values:

  • NONE: No health checks are performed.

  • ECS: Health checks are performed on instances in the scaling group. This value enables health checks for scaling groups of both the ECS and ECI types.

  • LOAD_BALANCER: The instance health status is based on health check results from the attached load balancer. This option does not support Classic Load Balancer (CLB) instances.

Default value: ECS.

Note

To enable both instance health checks and load balancer health checks, use the HealthCheckTypes parameter.

ECS

ScalingPolicy

string

No

The reclamation mode of the scaling group. Valid values:

  • recycle: The reclamation mode is Economical Mode.

  • release: The reclamation mode is Release Mode.

  • forcerelease: The reclamation mode is Force Release Mode.
    Note

    A forced release is equivalent to a power-off operation, which erases data in the memory and ephemeral storage of the instances. This data cannot be recovered. Use this option with caution.

  • forcerecycle: The reclamation mode is Force Economical Mode.
    Note

    A forced stop is equivalent to a power-off operation, which erases data in the memory and ephemeral storage of the instances. This data cannot be recovered. Use this option with caution.

ScalingPolicy specifies the reclamation mode of the scaling group. The specific action taken when an instance is removed from the scaling group is determined by the RemovePolicy parameter of the RemoveInstances operation. For more information, see RemoveInstances.

recycle

ClientToken

string

No

A client-generated token to ensure the idempotence of the request.

The token must be unique across requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

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

OnDemandBaseCapacity

integer

No

The minimum number of on-demand instances required in the scaling group. Valid values: 0 to 1,000. If the number of on-demand instances is less than this value, Auto Scaling preferentially creates on-demand instances.

30

OnDemandPercentageAboveBaseCapacity

integer

No

The percentage of on-demand instances among the excess instances after the minimum number of on-demand instances (OnDemandBaseCapacity) is met. Valid values: 0 to 100.

20

SpotInstanceRemedy

boolean

No

If set to true, Auto Scaling attempts to create a new instance to replace a spot instance that is about to be reclaimed.

true

CompensateWithOnDemand

boolean

No

This parameter is effective only when MultiAZPolicy is set to COST_OPTIMIZED. If true, Auto Scaling creates on-demand instances to meet capacity requirements when spot instances are unavailable due to price or inventory. Valid values:

  • true: Yes.

  • false: No.

Default value: true.

true

SpotInstancePools

integer

No

The number of instance types to use. The scaling group creates spot instances in a balanced manner across the specified number of lowest-cost instance types. Valid values: 1 to 10.

5

DesiredCapacity

integer

No

The desired number of instances in the scaling group. Auto Scaling automatically maintains this number of instances. The value must be less than or equal to MaxSize and greater than or equal to MinSize.

5

GroupDeletionProtection

boolean

No

Specifies whether to enable deletion protection for the scaling group. Valid values:

  • true: Enables deletion protection. The scaling group cannot be deleted.

  • false: Disables deletion protection.

Default value: false.

true

GroupType

string

No

The type of instances managed by the scaling group. Valid values:

  • ECS: The scaling group manages ECS instances.

  • ECI: The scaling group manages ECI instances.

Default value: ECS.

ECS

ContainerGroupId

string

No

The ID of the ECI instance, also known as the container group ID.

eci-uf6fonnghi50u374****

VSwitchIds

array

No

The IDs of one or more vSwitches. If you specify this parameter, the VSwitchId parameter is ignored. If you specify this parameter, the network type of the scaling group is Virtual Private Cloud (VPC).

If you specify multiple vSwitches:

  • They must belong to the same VPC.

  • They can be in different availability zones.

  • The vSwitches are prioritized based on their order in the list, with the first vSwitch having the highest priority. If an instance cannot be created in the availability zone of a higher-priority vSwitch, Auto Scaling automatically attempts to create the instance in the availability zone of the next-highest-priority vSwitch.

Note

If you do not specify the VSwitchId or VSwitchIds parameter, the network type of the scaling group defaults to classic network.

string

No

The IDs of one or more vSwitches. If you specify this parameter, the VSwitchId parameter is ignored. If you specify this parameter, the network type of the scaling group is Virtual Private Cloud (VPC).

If you specify multiple vSwitches:

  • They must belong to the same VPC.

  • They can be in different availability zones.

  • The vSwitches are prioritized based on their order in the list, with the first vSwitch having the highest priority. If an instance cannot be created in the availability zone of a higher-priority vSwitch, Auto Scaling automatically attempts to create the instance in the availability zone of the next-highest-priority vSwitch.

Note

If you do not specify the VSwitchId or VSwitchIds parameter, the network type of the scaling group defaults to classic network.

vsw-bp14zolna43z266bq****

LifecycleHooks

array<object>

No

The list of lifecycle hooks.

object

No

The list of lifecycle hooks.

DefaultResult

string

No

The action to take after the wait state ends. Valid values:

  • CONTINUE: Continues the scale-out or scale-in activity.

  • ABANDON: Aborts the scale-out activity by releasing the created instances, or aborts the scale-in activity by keeping the instances in the scaling group.

If a scale-in (SCALE_IN) activity triggers multiple lifecycle hooks, and the DefaultResult of one of the lifecycle hooks is ABANDON, the wait state of the other lifecycle hooks ends prematurely. In other cases, the action is determined by the last lifecycle hook to complete.

Default value: CONTINUE.

CONTINUE

LifecycleHookName

string

No

The name of the lifecycle hook. The name cannot be modified after it is specified. If you do not specify a name, the ID of the lifecycle hook is used.

lifecyclehook****

LifecycleTransition

string

No

The type of scaling activity to which the lifecycle hook applies. Valid values:

  • SCALE_OUT: A scale-out activity.

  • SCALE_IN: A scale-in activity.

Note

This parameter is required if you specify a lifecycle hook for the scaling group. Other related parameters are optional.

SCALE_OUT

NotificationMetadata

string

No

A fixed string of information for the wait state of a scaling activity. The value cannot exceed 4,096 characters in length. When Auto Scaling sends a message to the specified notification recipient, it includes the value of this parameter. This allows you to manage and categorize notifications. This parameter is valid only when you specify the NotificationArn parameter.

Test

NotificationArn

string

No

The Alibaba Cloud Resource Name (ARN) of the notification recipient for the lifecycle hook. Message Service (MNS) queues and topics are supported. The format is acs:ess:{region}:{account-id}:{resource-relative-id}.

  • region: the region where the scaling group is located.

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

Examples:

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

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

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

HeartbeatTimeout

integer

No

The wait time that is defined in the lifecycle hook for a scaling activity. After the wait time expires, the next action is performed. Valid values: 30 to 21600. Unit: seconds.

After you create a lifecycle hook, you can call the RecordLifecycleActionHeartbeat operation to extend the wait time of an instance, or call the CompleteLifecycleAction operation to end the wait state of the scaling activity in advance.

Default value: 600.

600

VServerGroups

array<object>

No

The vServer groups to associate with the scaling group.

array<object>

No

The vServer groups to associate with the scaling group.

VServerGroupAttributes

array<object>

No

The attributes of the backend server group.

object

No

The attributes of the backend server group.

VServerGroupId

string

No

The ID of the vServer group.

rsp-bp1443g77****

Weight

integer

No

The weight of an instance as a backend server after the instance is added to the vServer group. The higher the weight, the more access requests are distributed to the instance. If the weight is 0, no access requests are distributed to the instance. Valid values: 0 to 100.

Default value: 50.

100

Port

integer

No

The port number used by an instance after it is added to the vServer group. Valid values: 1 to 65535.

22

LoadBalancerId

string

No

The ID of the Classic Load Balancer (CLB) instance to which the vServer group belongs.

lb-bp1u7etiogg38yvwz****

Tags

array<object>

No

The tags to apply to the scaling group.

object

No

The tags to apply to the scaling group.

Key

string

No

The key of the tag.

Department

Value

string

No

The value of the tag.

Finance

Propagate

boolean

No

Specifies whether the tag can be propagated. Valid values:

  • true: The tag is propagated from the scaling group only to newly created instances, not to instances that are already running in the scaling group.

  • false: The tag is not propagated from the scaling group to any instances.

Default value: false.

false

LaunchTemplateOverrides

array<object>

No

The instance type information for extending the launch template.

object

No

The instance type information for extending the launch template.

InstanceType

string

No

To enable the scaling group to scale based on instance type capacity, you must specify both this parameter and LaunchTemplateOverrides.WeightedCapacity.

This parameter specifies the instance type, which overrides the instance type specified in the launch template.

Note

This parameter takes effect only when the LaunchTemplateId parameter is specified.

Must be a valid ECS instance type.

ecs.c5.xlarge

WeightedCapacity

integer

No

To enable the scaling group to scale based on instance type capacity, you must specify this parameter after you specify LaunchTemplateOverrides.InstanceType.

This parameter specifies the weight of the instance type, which represents the capacity of a single instance of that type in the scaling group. A higher weight means that fewer instances of this type are needed to meet the desired capacity.

Because instance types have different performance metrics, such as the number of vCPUs and memory size, you can assign different weights to different instance types based on your requirements.

Example:

  • Current capacity: 0.

  • Desired capacity: 6.

  • Capacity of ecs.c5.xlarge: 4.

To meet the desired capacity, the scaling group will create two ecs.c5.xlarge instances.

Note

During a scale-out activity, the capacity of the scaling group cannot exceed the sum of the maximum capacity (MaxSize) and the maximum weight of an instance type.

Valid values: 1 to 500.

4

SpotPriceLimit

number

No

The maximum hourly price for the instance type specified in LaunchTemplateOverride.InstanceType.

Note

This parameter takes effect only when the LaunchTemplateId parameter is specified.

0.025

AlbServerGroups

array<object>

No

The Application Load Balancer (ALB) server groups to associate with the scaling group.

object

No

The Application Load Balancer (ALB) server groups to associate with the scaling group.

AlbServerGroupId

string

No

The ID of the ALB server group.

A scaling group can be associated with a limited number of ALB server groups. To view or request a quota increase, go to Quota Center.

sgp-ddwb0y0g6y9bjm****

Weight

integer

No

The weight of an instance as a backend server after the instance is added to the ALB server group. The higher the weight, the more access requests are distributed to the instance. If the weight is 0, no access requests are distributed to the instance. Valid values: 0 to 100.

100

Port

integer

No

The port number used by an instance after it is added to the ALB server group. Valid values: 1 to 65535.

22

ServerGroups

array<object>

No

The load balancer server groups.

Note

You cannot specify the same server group in both AlbServerGroups and ServerGroups.

object

No

The load balancer server groups.

ServerGroupId

string

No

The ID of the server group.

sgp-5yc3bd9lfyh*****

Type

string

No

The type of the server group. Valid values:

  • ALB: Application Load Balancer.

  • NLB: Network Load Balancer.

  • GWLB: Gateway Load Balancer.

ALB

Weight

integer

No

The weight of an instance as a backend server after the instance is added to the server group. Valid values: 0 to 100.

A higher weight indicates that more access requests are distributed to the instance. If the weight is 0, no access requests are distributed to the instance.

Note

This parameter is required for ALB and NLB server groups. You cannot set this parameter for GWLB server groups.

100

Port

integer

No

The port number used by an instance after it is added to the server group. Valid values: 1 to 65535.

22

AzBalance

boolean

No

Specifies whether to evenly distribute the capacity of the scaling group across multiple availability zones. This parameter is valid only when MultiAZPolicy is set to COMPOSABLE. Valid values:

  • true: The capacity of the scaling group is evenly distributed across multiple availability zones.

  • false: The capacity of the scaling group is not evenly distributed across multiple availability zones.

Note

If MultiAZPolicy is set to COMPOSABLE and AzBalance is set to true, the effect is the same as setting MultiAZPolicy to BALANCE.

Default value: false.

false

AllocationStrategy

string

No

The capacity allocation policy determines how the scaling group selects available instance types to meet capacity requirements. The policy applies to both on-demand and preemptible capacity (effective only when the MultiAZPolicy parameter is set to COMPOSABLE). Valid values:

  • priority: Creates instances in the order of the configured instance types.

  • lowestPrice: Create instances based on the price per vCPU of instance types, from lowest to highest.

Default value: priority.

priority

SpotAllocationStrategy

string

No

The distribution strategy for spot capacity. You can use this parameter to specify a separate strategy for spot capacity (effective only when the MultiAZPolicy parameter is set to COMPOSABLE). Valid values:

  • priority: Creates instances in the order of the configured instance types.

  • lowestPrice: Creates instances in ascending order of the price per vCPU of the instance types.

Default value: priority.

lowestPrice

SyncAlarmRuleToCms

boolean

No

Note

This parameter is not yet available.

false

MaxInstanceLifetime

integer

No

The maximum lifetime of an instance in the scaling group. Unit: seconds.

Value range: [86400, Integer.maxValue].

Default value: null.

null

CustomPolicyARN

string

No

The ARN of the custom scale-in policy function. This parameter is valid only when the first removal policy in RemovalPolicies is CustomPolicy.

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

ResourceGroupId

string

No

The ID of the resource group to which the new scaling group belongs.

Note

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

rg-123******

LoadBalancerConfigs

array<object>

No

The load balancer configurations.

object

No

The load balancer configurations.

LoadBalancerId

string

No

The ID of the CLB instance.

lb-2zen1olhfg9yw3f4q****

Weight

integer

No

The weight of an instance as a backend server after the instance is added to the SLB server group. The higher the weight, the more access requests are distributed to the instance. If the weight is 0, no access requests are distributed to the instance. Valid values: 0 to 100.

10

HealthCheckTypes

array

No

The health check methods for the scaling group.

Note

You can use this parameter to set multiple values and enable multiple health check options. If you set the HealthCheckType parameter, this parameter is ignored.

string

No

The health check methods for the scaling group. Valid values:

  • NONE: No health checks are performed.

  • ECS: Health checks are performed on instances in the scaling group. This value enables health checks for scaling groups of both the ECS and ECI types.

  • LOAD_BALANCER: The instance health status is based on health check results from the attached load balancer. This option does not support Classic Load Balancer (CLB) instances.

Default value: ECS.

ECS

DBInstances

array<object>

No

The databases that are associated with the scaling group.

object

No

The database configurations that are associated with the scaling group.

DBInstanceId

string

No

The ID of the database instance.

rm-m5eqju85s45mu0***

Type

string

No

The type of the database. Valid values:

  • RDS

  • Redis

  • MongoDB

Default value: RDS.

RDS

AttachMode

string

No

The method that is used to associate the scaling group with the database. Valid values:

  • SecurityIp: The IP address whitelist mode. This mode automatically adds the scaled-out instances to the IP address whitelist of the database. This mode is supported only by RDS databases.

  • SecurityGroup: The security group mode. This mode adds the security group of the scaling configuration to the security group whitelist of the database. This allows instances in the security group to access the database.

SecurityIp

StopInstanceTimeout

integer

No

The timeout period for the system to wait for an ECS instance to be stopped during a scale-in event. Unit: seconds. Valid values: 30 to 240.

Note
  • This parameter takes effect only during scale-in events when ScalingPolicy is set to release.

  • If this parameter is set, the system waits for the specified StopInstanceTimeout period for the instance to be stopped. If the instance is not stopped after the timeout period, the scale-in process continues regardless of the instance status.

  • If this parameter is not set, the system waits for an extended period for the instance to be stopped. The scale-in process continues only after the instance is stopped. If the instance fails to stop, the scale-in process is rolled back, and the scale-in event fails.

60

CapacityOptions

object

No

The capacity options.

OnDemandBaseCapacity

integer

No

The minimum number of on-demand instances required in the scaling group. When the number of on-demand instances in the scaling group is less than this value, the system preferentially creates on-demand instances. Valid values: 0 to 1,000.

When MultiAZPolicy is set to COMPOSABLE, the default value is 0.

30

OnDemandPercentageAboveBaseCapacity

integer

No

The percentage of on-demand instances among the excess instances after the OnDemandBaseCapacity requirement is met. Valid values: 0 to 100.

When MultiAZPolicy is set to COMPOSABLE, the default value is 100.

20

CompensateWithOnDemand

boolean

No

When MultiAZPolicy is set to COST_OPTIMIZED, this parameter specifies whether to automatically create on-demand instances to meet capacity requirements when spot instances are unavailable due to price or inventory. Valid values:

  • true: Yes.

  • false: No.

Default value: true.

true

SpotAutoReplaceOnDemand

boolean

No

After you enable CompensateWithOnDemand, if the on-demand percentage exceeds the OnDemandPercentageAboveBaseCapacity ratio, the system attempts to replace on-demand capacity with spot capacity. A common scenario is when CompensateWithOnDemand leads to on-demand instances being created due to spot inventory or price issues. To avoid the prolonged existence of these on-demand instances, the system attempts to replace the excess on-demand capacity with spot instances. Valid values:

  • true: Allows replacement.

  • false: Does not allow replacement.

Default value: false.

false

PriceComparisonMode

string

No

The price comparison mode for the cost optimization strategy of the scaling group. Valid values:

  • PricePerUnit: Compares prices based on per-unit capacity.

    The capacity of an instance in a scaling group is equal to the weight set for the instance type, with a default of 1, meaning one ECS instance equals one unit of capacity.

  • PricePerVCpu: Compares prices based on per-vCPU price.

Default value: PricePerUnit.

PricePerUnit

BalanceMode

string

No

The zone balancing mode is effective only when enabled. Valid values:

  • BalancedBestEffort: If a resource fails to be created in an availability zone, the system falls back to other availability zones to ensure best-effort delivery.

  • BalancedOnly: If resource creation fails in an availability zone, the system does not fall back to other availability zones. The scaling activity is partially successful, which prevents an excessive imbalance of resources across different availability zones.

Default value: BalancedBestEffort.

BalancedBestEffort

AutoRebalance

boolean

No

Specifies whether to enable automatic balancing for the scaling group. This setting takes effect only when BalancedOnly is enabled for a scaling group that is balanced across availability zones. Value range:

  • false: Does not enable automatic balancing for the scaling group.

  • true: When automatic balancing for the scaling group is enabled, the scaling group automatically detects the capacity across availability zones. If the capacity is imbalanced, the scaling group proactively performs scaling across availability zones to rebalance the capacity.

Default value: false.

false

Response elements

Element

Type

Description

Example

object

RequestId

string

The ID of the request.

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

ScalingGroupId

string

The ID of the scaling group.

asg-bp14wlu85wrpchm0****

Examples

Success response

JSON format

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

Error codes

HTTP status code

Error code

Error message

Description

404 ResourceNotAvailable.VPCNetwork The specified zone does not support vpc network or sold out.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.