All Products
Search
Document Center

Auto Scaling:ModifyScalingGroup

Last Updated:Sep 17, 2026

If you need to automatically increase or decrease the number of instances of a specific type based on business changes and policies, you can configure a scaling group to automatically adjust your compute capacity (that is, the number of instances). If the current scaling group attributes no longer meet your business requirements, you can call the ModifyScalingGroup operation to modify scaling group attributes such as the maximum number of instances, minimum number of instances, or expected number of instances. This way, you do not need to create a scaling group again or reconfigure related attributes, which saves time and resources.

Operation description

Operation description

  • The following parameters cannot be modified:

  • You can invoke this operation only when the scaling group is in the Active or Inactive state.

  • Enabling a new scaling configuration does not affect ECS instances or elastic container instances that were created based on the previous scaling configuration and are still running.

  • If you modify MaxSize and the number of ECS or elastic container instances in the scaling group exceeds the new MaxSize value, Auto Scaling automatically removes instances from the scaling group until the number of instances equals the MaxSize value.

  • If you modify MinSize and the number of ECS or elastic container instances in the scaling group is less than the new MinSize value, Auto Scaling automatically adds instances to the scaling group until the number of instances equals the MinSize value.

  • If DesiredCapacity is set for the scaling group and you modify DesiredCapacity, Auto Scaling automatically adds or removes ECS or elastic container instances to ensure that the number of instances in the scaling group equals the DesiredCapacity value.

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 must be unique within a region. The name must be 2 to 64 characters in length and can contain digits, uppercase letters, lowercase letters, Chinese characters, underscores (_), hyphens (-), and periods (.). It must start with a digit, letter, or Chinese character.

scalinggroup****

MinSize

integer

No

The minimum number of ECS instances or elastic container instances in the scaling group. When the number of ECS or elastic container instances in the scaling group is less than the MinSize value, Auto Scaling performs automatic creation of ECS instances or elastic container instances.

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. When the number of ECS or elastic container instances in the scaling group exceeds the MaxSize value, Auto Scaling automatically removes instances.

The valid values of MaxSize depend on your Auto Scaling usage. Go to Quota Center to check the quota for Maximum number of instances in a scaling group.

For example, if the quota for Maximum number of instances in a scaling group is 2000, the valid values of MaxSize are 0 to 2000.

99

DefaultCooldown

integer

No

The cooldown time after a scaling activity (adding or removing ECS instances or elastic container instances) is complete. Valid values: 0 to 86400. Unit: seconds.

During the cooldown time, the scaling group does not execute other scaling activities. This parameter applies only to scaling activities triggered by CloudMonitor event-triggered tasks.

600

RemovalPolicy.1

string

No

The first-priority scale-in policy for removing ECS instances from the scaling group. Valid values:

  • OldestInstance: removes the ECS instance that was earliest 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 (Function).

Note

The scaling configuration mentioned in OldestScalingConfiguration refers to the instance configuration source, including scaling configurations and launch templates. CustomPolicy can be set only as the first-priority scale-in policy. When you specify CustomPolicy, you must also specify the CustomPolicyARN parameter.

OldestScalingConfiguration

RemovalPolicy.2

string

No

The second-priority scale-in policy for removing ECS instances from the scaling group. Valid values:

  • OldestInstance: removes the ECS instance that was earliest 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.

Note

The scaling configuration mentioned in OldestScalingConfiguration refers to the instance configuration source, including scaling configurations and launch templates.

NewestInstance

RemovalPolicy.3

string

No

The third-priority scale-in policy for removing ECS instances from the scaling group. Valid values:

  • OldestInstance: removes the ECS instance that was earliest 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.

Note

The scaling configuration mentioned in OldestScalingConfiguration refers to the instance configuration source, including scaling configurations and launch templates.

OldestInstance

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: Health checks are disabled.

  • ECS: Health checks are performed on instances in the scaling group. This value applies to both ECS-type and ECI-type scaling groups.

  • LOAD_BALANCER: The health check status of instances is determined based on load balancing health check results. Classic Load Balancer (CLB) is not supported.

Default value: ECS.

Note

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

ECS

LaunchTemplateId

string

No

The ID of the launch template from which the scaling group obtains launch configuration information.

lt-m5e3ofjr1zn1aw7****

LaunchTemplateVersion

string

No

The version of the launch template. Valid values:

  • A fixed template version number.

  • Default: always uses the default version of the template.

  • Latest: always uses the latest version of the template.

Default

OnDemandBaseCapacity

integer

No

The minimum number of pay-as-you-go instances required in the scaling group. Valid values: 0 to 1000. When the number of pay-as-you-go instances is less than this value, pay-as-you-go instances are preferentially created.

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

30

OnDemandPercentageAboveBaseCapacity

integer

No

The percentage of pay-as-you-go instances among the excess instances after the minimum number of pay-as-you-go instances (OnDemandBaseCapacity) is met. Valid values: 0 to 100.

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

20

SpotInstanceRemedy

boolean

No

Specifies whether to supplement spot instances. When this feature is enabled and the scaling group receives a system message that a spot instance is about to be reclaimed, the scaling group attempts to create a new instance to replace the spot instance that 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 spot instances cannot be created due to reasons such as cost or insufficient inventory. This parameter takes effect only when the MultiAZPolicy parameter of the CreateScalingGroup operation is set to COST_OPTIMIZED. Valid values:

  • true: Pay-as-you-go instances are allowed.

  • false: Pay-as-you-go instances are not allowed.

true

SpotInstancePools

integer

No

The number of available instance types. The scaling group creates spot instances of multiple types at the lowest cost. Valid values: 0 to 10.

When the MultiAZPolicy parameter is set to COMPOSABLE, the default value is 2.

5

DesiredCapacity

integer

No

The expected number of ECS instances or elastic container instances in the scaling group. Setting this parameter enables the expected number of instances feature. The scaling group automatically maintains the number of ECS or elastic container instances at the expected number. Valid values: MinSize ≤ DesiredCapacity ≤ MaxSize.

Note

If you disable and then re-enable the expected number of instances feature, you must set the DesiredCapacity value again.

5

GroupDeletionProtection

boolean

No

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

  • true: Deletion protection is enabled. The scaling group cannot be deleted.

  • false: Deletion protection is disabled.

true

MultiAZPolicy

string

No

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

  • PRIORITY: Instances are scaled based on the priority of the vSwitches (VSwitchIds.N). Auto Scaling preferentially attempts to scale instances in the zone of the highest-priority vSwitch. If the scaling fails, Auto Scaling attempts to scale instances in the zone of the next highest-priority vSwitch.

  • COST_OPTIMIZED: During scale-out, Auto Scaling attempts to create ECS instances in ascending order of vCPU unit price. During scale-in, Auto Scaling attempts to remove ECS instances in descending order of vCPU unit price. When the scaling configuration specifies preemptible billing methods for multiple instance types, spot instances are preferentially created. You can use the CompensateWithOnDemand parameter to specify whether Auto Scaling automatically attempts to create pay-as-you-go instances when spot instances cannot be created.

    Note

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

  • BALANCE: ECS instances are evenly distributed across the multiple zones specified for the scaling group. If the zones become unbalanced due to reasons such as insufficient inventory, you can call the RebalanceInstance operation to rebalance resources.

  • COMPOSABLE: A composite policy that allows you to customize a combination of the preceding multi-zone scaling policies. You can combine the preceding policies for active instance types based on your billable methods as needed.

PRIORITY

VSwitchIds

array

No

The IDs of one or more vSwitches.

This parameter takes effect only when the network type of the scaling group is VPC. The specified vSwitches must belong to the same VPC as the scaling group.

The vSwitches can span multiple zones. The priority of vSwitches is sorted in ascending numerical order, where 1 indicates the highest priority. When an ECS instance cannot be created in the zone of a higher-priority vSwitch, the system automatically selects the next highest-priority vSwitch.

vsw-bp1oo2a7isyrb8igf****

string

No

The IDs of one or more vSwitches. Valid values of N: 1 to 5.

This parameter takes effect only when the network type of the scaling group is VPC. The specified vSwitches must belong to the same VPC as the scaling group.

The vSwitches can span multiple zones. The priority of vSwitches is sorted in ascending numerical order, where 1 indicates the highest priority. When an ECS instance cannot be created in the zone of a higher-priority vSwitch, the system automatically selects the next highest-priority vSwitch.

vsw-bp1oo2a7isyrb8igf****

LaunchTemplateOverride

array<object>

No

The launch template override information.

object

No

The launch template override information.

InstanceType

string

No

To scale the scaling group based on the capacity of instance types, specify both this parameter and LaunchTemplateOverride.N.WeightedCapacity.

This parameter specifies the instance type, which overrides the instance type in the launch template. You can specify N values for this parameter to extend the launch template to support N instance types. Valid values of N: 1 to 20.

Note

This parameter takes effect only when the LaunchTemplateId parameter specifies a launch template.

Valid values of InstanceType: ECS instance types that are available for purchase. For more information, see Instance families.

ecs.c5.xlarge

WeightedCapacity

integer

No

To scale the scaling group based on the capacity of instance types, specify this parameter after you specify LaunchTemplateOverride.N.InstanceType. The two parameters correspond to each other on a one-to-one basis, and the values of N must be the same.

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

Because instance types differ in 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.

  • Expected capacity: 6.

  • Capacity of ecs.c5.xlarge: 4.

To meet the expected capacity, the scaling group scales out two ecs.c5.xlarge instances.

Note

During scale-out, the capacity of the scaling group cannot exceed the sum of MaxSize and the maximum weight of the instance types.

Valid values of WeightedCapacity: 1 to 500.

4

SpotPriceLimit

number

No

The maximum bid price for the instance type specified by LaunchTemplateOverride.N.InstanceType. You can specify N values for this parameter to extend the launch template to support N instance types. Valid values of N: 1 to 20.

Note

This parameter takes effect only when the LaunchTemplateId parameter specifies a launch template.

0.025

AzBalance

boolean

No

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

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

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

Default value: false.

false

AllocationStrategy

string

No

The capacity allocation strategy that determines how the scaling group selects available instance types to meet capacity requirements. The capacity allocation strategy applies to both pay-as-you-go and spot capacity. This parameter takes effect only when the MultiAZPolicy parameter is set to COMPOSABLE. Valid values:

  • priority: Instances are created in the order of the configured instance types.

  • lowestPrice: Instances are created in ascending order of vCPU unit price.

Default value: priority.

priority

SpotAllocationStrategy

string

No

The spot capacity allocation strategy. You can use this parameter to separately specify the allocation strategy for spot capacity. This parameter takes effect only when the MultiAZPolicy parameter is set to COMPOSABLE. Valid values:

  • priority: Instances are created in the order of the configured instance types.

  • lowestPrice: Instances are created in ascending order of vCPU unit price.

Default value: priority.

lowestPrice

MaxInstanceLifetime

integer

No

The maximum amount of time that an instance can remain in the scaling group. Unit: seconds.

Valid values: 0 or [86400, Integer.maxValue]. A value of 0 clears the previously set MaxInstanceLifetime value (that is, MaxInstanceLifetime is not set).

Default value: null.

Note

This parameter is not supported for ECI-type scaling groups or scaling groups with the economical mode enabled.

86400

CustomPolicyARN

string

No

The Alibaba Cloud Resource Name (ARN) of the custom scale-in policy (Function). This parameter takes effect only when the first scale-in policy in RemovalPolicies is set to CustomPolicy.

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 only when no scaling activity is in progress in the scaling group. When the expected number of instances feature is disabled, the current DesiredCapacity attribute of the scaling group is cleared, but the current number of instances in the scaling group remains unchanged.

false

ScalingPolicy

string

No

The reclaim mode of the scaling group. Valid values:

  • recycle: The scaling group uses the shutdown and recycle mode.

  • release: The scaling group uses the release mode.

  • forcerelease: The scaling group uses the forced release mode.

    Note

    If you select forcerelease, running instances are forcefully released during scale-in activities. Forcefully releasing an instance is equivalent to a power-off operation, which erases temporary data in the memory and storage of the instance. The data cannot be recovered. Proceed with caution.

  • forcerecycle: The scaling group uses the forced shutdown and recycle mode.

    Note

    If you select forcerecycle, running instances are forcefully shut down during scale-in activities. Forcefully shutting down an instance is equivalent to a power-off operation, which erases temporary data in the memory and storage of the instance. The data cannot be recovered. Proceed with caution.

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

recycle

HealthCheckTypes

array

No

The health check modes of the scaling group.

Note

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

string

No

The list of health check modes for the scaling group. Valid values:

  • NONE: Health checks are disabled.

  • ECS: Health checks are performed on instances in the scaling group. This value applies to both ECS-type and ECI-type scaling groups.

  • LOAD_BALANCER: The health check status of instances is determined based on load balancing health check results. Classic Load Balancer (CLB) is not supported.

Default value: ECS.

ECS

StopInstanceTimeout

integer

No

The timeout period for waiting for an ECS instance to stop during a scale-in process. Unit: seconds. Valid values: 30 to 240.

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

  • If this parameter is set, the system waits up to the StopInstanceTimeout period for the instance to stop. After the timeout, the scale-in process continues regardless of whether the instance is stopped.

  • If this parameter is not set, the system waits indefinitely for the instance to stop. The scale-in process continues only after the instance is stopped. If the instance fails to stop, the scale-in process will rollback and the scale-in fails.

  • Setting this parameter to 0 clears the parameter configuration.

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 in the scaling group is less than this value, the system preferentially creates pay-as-you-go instances. Valid values: 0 to 1000.

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

30

OnDemandPercentageAboveBaseCapacity

integer

No

The percentage of pay-as-you-go instances among the excess instances after the minimum number of pay-as-you-go instances (OnDemandBaseCapacity) is met. Valid values: 0 to 100.

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

20

CompensateWithOnDemand

boolean

No

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

  • true: Pay-as-you-go instances are allowed.

  • false: Pay-as-you-go instances are not allowed.

true

SpotAutoReplaceOnDemand

boolean

No

Specifies whether to use spot instances to replace pay-as-you-go instances when CompensateWithOnDemand is enabled and the pay-as-you-go ratio exceeds the OnDemandPercentageAboveBaseCapacity ratio. A common scenario is when CompensateWithOnDemand causes spot instances to be downgraded to pay-as-you-go instances due to spot inventory or pricing issues. To prevent pay-as-you-go instances from persisting for an extended period, the system attempts to replace the excess pay-as-you-go capacity with spot instances. Valid values:

  • true: Replacement is allowed.

  • false: Replacement is not allowed.

Default value: false.

true

PriceComparisonMode

string

No

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

  • PricePerUnit: Prices are compared based on the price per unit of capacity.

    The capacity of an instance in the scaling group equals the weight configured for the instance type. The default weight is 1, which means one ECS instance occupies a capacity of 1.

  • PricePerVCpu: Prices are compared based on the price per vCPU.

Default value: PricePerUnit.

PricePerUnit

BalanceMode

string

No

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

  • BalancedBestEffort: When resource creation fails in a zone, the system falls back to other zones to ensure best-effort resource delivery.

  • BalancedOnly: When resource creation fails in a zone, the system does not fall back to other zones. The scale-out activity partially succeeds to prevent excessive imbalance of resources across zones.

Default value: BalancedBestEffort.

BalancedBestEffort

AutoRebalance

boolean

No

Specifies whether to enable automatic rebalancing for the scaling group. This parameter takes effect only when BalancedOnly is enabled for a zone-balanced scaling group. Valid values:

  • false: Automatic rebalancing is disabled.

  • true: When automatic rebalancing is enabled, the scaling group automatically detects the capacity across zones. When the capacity is unbalanced across zones, the scaling group proactively scales in and out to rebalance the capacity.

Default value: false.

false

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

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.