All Products
Search
Document Center

Auto Scaling:ModifyScalingGroup

Last Updated:Aug 28, 2026

Modifies the attributes of a scaling group, such as the maximum, minimum, and expected numbers of instances. This eliminates the need to recreate and reconfigure scaling groups.

Operation description

  • The following parameters cannot be modified:

    • RegionId

    • LoadBalancerId

    Note

    To modify an SLB instance, use the AttachLoadBalancers and DetachLoadBalancers APIs.

    • DBInstanceId

    Note

    To modify an RDS instance, use the AttachDBInstances and DetachDBInstances APIs.

  • You can invoke this API only when the scaling group status is Active or Inactive.

  • Enabling a new scaling configuration does not affect ECS instances or ECI instances that were created using an earlier scaling configuration and are currently running.

  • If MaxSize is modified such that the current number of ECS or ECI instances in the scaling group exceeds MaxSize, the scaling group automatically removes ECS or ECI instances until the instance count equals MaxSize.

  • If MinSize is modified such that the current number of ECS or ECI instances in the scaling group falls below MinSize, the scaling group automatically adds ECS or ECI instances until the instance count equals MinSize.

  • If DesiredCapacity is set for the scaling group and then modified such that the current number of ECS or ECI instances differs from the new DesiredCapacity, the scaling group automatically adds or removes ECS or ECI instances until the instance count equals DesiredCapacity.

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:ModifyScalingGroup

update

*ScalingGroup

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

None None

Request parameters

Parameter

Type

Required

Description

Example

ScalingGroupId

string

Yes

The ID of the scaling group that you want to modify.

asg-bp1ffogfdauy0jw0****

ScalingGroupName

string

No

The name of the scaling group. The name of each 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 (.). The name must start with a letter or a digit.

scalinggroup****

MinSize

integer

No

The minimum number of ECS instances or elastic container instances in the scaling group. If the current number of instances falls below this value, Auto Scaling automatically adds instances to meet the minimum.

Note

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

1

MaxSize

integer

No

The maximum number of ECS instances or elastic container instances in the scaling group. If the current number of instances exceeds this value, Auto Scaling automatically removes the surplus instances.

The value range of MaxSize depends on your Auto Scaling quota. You can go to Quota Center to check the maximum number of instances that a single 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.

99

DefaultCooldown

integer

No

The cooldown period of the scaling group. This parameter is available only if you set ScalingRuleType to SimpleScalingRule. Valid values: 0 to 86400. Unit: seconds.

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

600

RemovalPolicies

array

No

The policy that is used to remove ECS instances from the scaling group. 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 most recently added to the scaling group.

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

string

No

The policy that is used to remove ECS instances from the scaling group. 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 most recently added to the scaling group.

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

NewestInstance

ActiveScalingConfigurationId

string

No

The ID of the active scaling configuration in the scaling group.

asc-bp17pelvl720x5ub****

HealthCheckType

string

No

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 ECS type or Elastic Container Instance type.

  • LOAD_BALANCER: Auto Scaling checks the health status of instances in the scaling group based on the health check results of load balancers. The health check results of Classic Load Balancer (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.

ECS

LaunchTemplateId

string

No

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

lt-m5e3ofjr1zn1aw7****

LaunchTemplateVersion

string

No

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.

Default

OnDemandBaseCapacity

integer

No

The minimum number of pay-as-you-go instances that must be included 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 the MultiAZPolicy parameter to COMPOSABLE Policy, the default value is 0.

30

OnDemandPercentageAboveBaseCapacity

integer

No

The expected percentage of pay-as-you-go instances in the excess instances when the minimum number of pay-as-you-go instances reaches the requirement. Valid values: 0 to 100.

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

20

SpotInstanceRemedy

boolean

No

Specifies whether to supplement preemptible instances. If set to true, Auto Scaling creates a replacement instance when it receives a notification that a preemptible instance is about to be reclaimed.

true

CompensateWithOnDemand

boolean

No

Specifies whether to automatically create pay-as-you-go instances to meet the required number of ECS instances when preemptible instances cannot be created due to cost or insufficient resources. This parameter takes effect only if you set MultiAZPolicy in the CreateScalingGroup operation to COST_OPTIMIZED. Valid values:

  • true

  • false

true

SpotInstancePools

integer

No

The number of instance types that you specify. Auto Scaling creates preemptible instances of multiple instance types that are provided at the lowest price. Valid values: 0 to 10.

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

5

DesiredCapacity

integer

No

The expected number of ECS instances or elastic container instances in the scaling group. Auto Scaling automatically maintains this number. The value must satisfy: MaxSize ≥ DesiredCapacity ≥ MinSize.

Note

If you re-enable the Expected Number of Instances feature, you must specify a value for DesiredCapacity again.

5

GroupDeletionProtection

boolean

No

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

  • true: enables deletion protection for the scaling group. This way, the scaling group cannot be deleted.

  • false: disables deletion protection for the scaling group.

true

MultiAZPolicy

string

No

The scaling policy for the multi-zone scaling group that contains ECS instances. Valid values:

  • PRIORITY: ECS instances are scaled based on the vSwitch priority. The first vSwitch specified by using the VSwitchIds parameter has the highest priority. Auto Scaling preferentially scales instances in the zone where the vSwitch that has the highest priority resides. If the scaling fails, Auto Scaling scales instances in the zone where the vSwitch that has the next highest priority resides.

  • COST_OPTIMIZED: During a scale-out activity, Auto Scaling preferentially creates ECS instances of the instance type that has the lowest unit price of vCPU. During a scale-in activity, Auto Scaling preferentially removes ECS instances of the instance types that have the highest unit price of vCPU. Auto Scaling preferentially creates preemptible instances when preemptible instance types are specified in the scaling configuration. You can use the CompensateWithOnDemand parameter to specify whether to automatically create pay-as-you-go instances when Auto Scaling fails to create preemptible instances.

Note

The COST_OPTIMIZED setting takes effect only when multiple instance types are specified or at least one instance type is specified for preemptible instances.

  • BALANCE: ECS instances are evenly distributed across zones that are specified in the scaling group. If ECS instances are unevenly distributed among zones due to insufficient resources, you can call the RebalanceInstance operation to evenly distribute the instances among the zones.

  • COMPOSABLE: You can flexibly combine the preceding policies based on your business requirements.

PRIORITY

VSwitchIds

array

No

The IDs of vSwitches.

This parameter takes effect only when the network type of the scaling group is virtual private cloud (VPC). The specified vSwitches and the scaling group must reside in the same VPC.

The vSwitches can reside in different zones. The vSwitches are sorted in ascending order. The first vSwitch specified by using the VSwitchIds parameter has the highest priority. If Auto Scaling fails to create ECS instances in the zone where the vSwitch that has the highest priority resides, Auto Scaling creates ECS instances in the zone where the vSwitch that has the next highest priority resides.

string

No

The IDs of vSwitches.

This parameter takes effect only when the network type of the scaling group is VPC. The specified vSwitches and the scaling group must reside in the same VPC.

The vSwitches can reside in different zones. The vSwitches are sorted in ascending order. The first vSwitch specified by using the VSwitchIds parameter has the highest priority. If Auto Scaling fails to create ECS instances in the zone where the vSwitch that has the highest priority resides, Auto Scaling creates ECS instances in the zone where the vSwitch that has the next highest priority resides.

vsw-bp1oo2a7isyrb8igf****

LaunchTemplateOverrides

array<object>

No

The information about the instance types that are extended in the launch template.

object

No

Details of the instance type that you specify by using the Extended Configurations feature of the launch template.

InstanceType

string

No

The instance type that you want to use to override the instance type that is specified in the launch template.

The instance type specified by using this parameter overwrites the instance type of the launch template.

Note

This parameter takes effect only if you specify LaunchTemplateId.

You can use this parameter to specify any instance types that are available for purchase.

ecs.c5.xlarge

WeightedCapacity

integer

No

If you want to scale the scaling group based on the instance types, you must specify LaunchTemplateOverrides.InstanceType before you specify this parameter. The two parameters have a one-to-one correspondence.

The weight specifies the capacity of an instance of the specified instance type in the scaling group.

A higher weight specifies that a smaller number of instances of the specified instance type are 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.

Sample capacity configurations:

  • Current capacity: 0.

  • Expected capacity: 6

  • Capacity of ecs.c5.xlarge: 4

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

Note

The total capacity of the scaling group is constrained and cannot surpass the combined total of the maximum group size defined by MaxSize and the highest weight assigned to any instance type.

Valid values of WeightedCapacity: 1 to 500.

4

SpotPriceLimit

number

No

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. You can specify 1 to 10 memory sizes, indicated by N.

Note

This parameter takes effect only if you use LaunchTemplateId to specify a launch template.

0.025

MaxInstanceLifetime

integer

No

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

Valid values: 86400 to Integer.maxValue. ``You can also set this parameter to 0. A value of 0 indicates that the instance has an unlimited life span in the scaling group.

Default value: null.

Note

You cannot specify this parameter for scaling groups that manage elastic container instances or scaling groups whose ScalingPolicy is set to recycle.

null

AzBalance

boolean

No

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

  • true

  • false

Default value: false.

false

AllocationStrategy

string

No

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

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

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

Default value: priority.

priority

SpotAllocationStrategy

string

No

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

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

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

Default value: priority.

lowestPrice

CustomPolicyARN

string

No

The ARN of the custom scaling policy (Function). This parameter takes effect only when you specify CustomPolicy as the first step of the instance removal policy.

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

DisableDesiredCapacity

boolean

No

Specifies whether to disable the expected number of instances feature for the scaling group. Valid values:

  • false: Enables the expected number of instances feature.

  • true: Disables the expected number of instances feature.

Note

You can set this parameter to true (to disable the expected number of instances feature) only when no scaling activity is currently running in the scaling group. When this feature is disabled, the current DesiredCapacity property of the scaling group is cleared, but the actual number of instances in the scaling group remains unchanged.

false

ScalingPolicy

string

No

The reclaim mode of the scaling group. Valid values:

  • recycle: economical mode

  • release: release mode

  • forcerelease: forced release mode

    **

    Note If you set the value to forcerelease, Auto Scaling forcibly releases instances that are in the Running state during scale-ins. Forced release is equivalent to power outage. If an instance is forcibly released, ephemeral data on the instance will be cleared and cannot be recovered. Exercise caution when you select this option.

  • forcerecycle: forced recycle mode

    **

    Note If you set the value to forcerecycle, Auto Scaling forcibly shuts down instances that are in the Running state during scale-ins. Forced shutdown is equivalent to power outage. If an instance is forcibly shut down, ephemeral data on the instance will be cleared and cannot be recovered. Exercise caution when you select this option.

ScalingPolicy specifies only the reclaim mode of the scaling group. RemovePolicy of the RemoveInstances operation specifies the manner how instances are removed from the scaling group. For more information, see RemoveInstances.

recycle

HealthCheckTypes

array

No

The health check mode of the scaling group.

Note

You can specify multiple values for this parameter to enable multiple health check options at the same time. If you specify HealthCheckType, this parameter is ignored.

string

No

The health check modes 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 ECS type or Elastic Container Instance type.

  • LOAD_BALANCER: Auto Scaling checks the health status of 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.

ECS

StopInstanceTimeout

integer

No

The timeout period for an ECS instance to enter the Stopped state during scale-in. 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 or not.
    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.




  • When you call the ModifyScalingGroup operation, you can set the value to 0. In this case, the system ignores this parameter.

60

CapacityOptions

object

No

The capacity options.

OnDemandBaseCapacity

integer

No

The minimum number of pay-as-you-go instances required in the scaling group. When the number of pay-as-you-go instances drops below the value of this parameter, Auto Scaling preferentially creates pay-as-you-go instances. Valid values: 0 to 1000.

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

30

OnDemandPercentageAboveBaseCapacity

integer

No

The percentage of additional pay-as-you-go instances beyond the minimum required by OnDemandBaseCapacity in the scaling group. Valid values: 0 to 100

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

20

CompensateWithOnDemand

boolean

No

Specifies whether to automatically create pay-as-you-go ECS instances to reach the required number of ECS instances when preemptible ECS instances cannot be created due to high prices or insufficient resources. This parameter takes effect only if you set MultiAZPolicy in the CreateScalingGroup operation to COST_OPTIMIZED. Valid values:

  • true

  • false

true

SpotAutoReplaceOnDemand

boolean

No

Specifies whether to replace pay-as-you-go instances with preemptible instances. When CompensateWithOnDemand is specified, Auto Scaling creates pay-as-you-go instances if preemptible instances are unavailable, which may result in a higher percentage of pay-as-you-go instances than the value of OnDemandPercentageAboveBaseCapacity. To avoid keeping surplus pay-as-you-go instances long-term, Auto Scaling replaces them with preemptible instances as soon as preemptible instance types become available. Valid values:

  • true

  • false

Default value: false.

true

PriceComparisonMode

string

No

The price comparison mode. Valid values:

  • PricePerUnit: compares prices based on capacity.

    The capacity of instances in a scaling group is determined by the weights of the instance types used. If no weight is specified, the default weight is 1, which specifies that each instance in the scaling group has a capacity of 1.

  • PricePerVCpu: compares prices based on the price per vCPU.

Default value: PricePerUnit.

PricePerUnit

BalanceMode

string

No

The zone balancing mode. This mode takes effect only when the zone balancing mode is enabled. Valid values:

  • BalancedBestEffort: If a resource fails to be created in a zone, the resource is downgraded to another zone. This ensures best-effort delivery of the resource.

  • BalancedOnly: If a resource fails to be created in a zone, the resource is not downgraded to another zone. The scale-out activity is partially successful to avoid excessive imbalance of resources in different zones.

Default value: BalancedBestEffort.

BalancedBestEffort

AutoRebalance

boolean

No

Whether to enable automatic rebalancing for the scaling group. This takes effect only when BalancedOnly is enabled for the scaling group. Valid values:

  • false: Auto rebalancing is disabled for the scaling group.

  • true: If Auto rebalancing is enabled, the scaling group automatically detects the capacity of the zone. If the capacity of the zone is unbalanced, the scaling group actively scales out the zone and re-balances the capacity of the zone.

Default value: false.

false

Response elements

Element

Type

Description

Example

object

RequestId

string

The ID of the request.

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

Examples

Success response

JSON format

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

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.