ModifyScalingGroup

Updated at:

Modifies the attributes of a scaling group. You can use scaling groups to automatically adjust computing capacity by adding or removing instances based on business needs and policies. If the current attributes of a scaling group no longer meet your business requirements, you can call this operation to modify attributes such as the maximum number of instances, minimum number of instances, or expected number of instances. This avoids the need to recreate the scaling group and reconfigure its attributes, which saves time and resource costs.

Operation description

Operation description

  • You cannot modify the following parameters:

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

  • When you enable a new scaling configuration, it does not affect the running ECS instances or ECI instances that were created based on earlier scaling configurations.

  • If you modify the MaxSize parameter and the current number of ECS instances or ECI instances in the scaling group exceeds the new MaxSize value, the scaling group automatically removes ECS instances or ECI instances until the number of ECS instances equals the MaxSize value.

  • If you modify the MinSize parameter and the current number of ECS instances or ECI instances in the scaling group is less than the new MinSize value, the scaling group automatically adds ECS instances or ECI instances until the number of ECS instances equals the MinSize value.

  • If the DesiredCapacity settings are applied for the scaling group and you modify this parameter, causing the current number of ECS instances or ECI instances to differ from the new DesiredCapacity value, the scaling group automatically adds or removes ECS instances or ECI instances until the number of ECS instances 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 to be modified.

asg-bp1ffogfdauy0jw0****

ScalingGroupName

string

No

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

scalinggroup****

MinSize

integer

No

The minimum number of ECS instances or ECI instances in the scaling group. When the number of ECS instances or ECI instances in the scaling group is less than the MinSize value, Auto Scaling performs automatic creation of ECS instances or ECI 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 or ECI instances in the scaling group. When the number of ECS or ECI instances in the scaling group is greater than the MaxSize value, Auto Scaling automatically removes ECS or ECI instances.

The value range of MaxSize depends on your Auto Scaling usage. Go to the Quota Center to view the quota value for the maximum number ECS instances in a single scaling group.

For example, if the quota value for the maximum number ECS instances in a single scaling group is 2000, the valid values of MaxSize range from 0 to 2000.

99

DefaultCooldown

integer

No

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

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

600

RemovalPolicy.1

string

No

The first scale-in policy used to remove ECS instances. Valid values:

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

  • NewestInstance: removes the ECS instances that were added to the scaling group at the latest point in time.

  • OldestScalingConfiguration: removes the ECS instances that were 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 in the scaling group, including scaling configurations and launch templates. CustomPolicy can only be specified as the first removal policy. If you specify CustomPolicy, you must also specify the CustomPolicyARN parameter.

OldestScalingConfiguration

RemovalPolicy.2

string

No

The second scale-in policy used to remove ECS instances. Valid values:

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

  • NewestInstance: removes the ECS instances that were added to the scaling group at the latest point in time.

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

Note

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

NewestInstance

RemovalPolicy.3

string

No

The third scale-in policy used to remove ECS instances. Valid values:

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

  • NewestInstance: removes the ECS instances that were added to the scaling group at the latest point in time.

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

Note

The scaling configuration mentioned in OldestScalingConfiguration refers to the instance configuration source in the scaling group, 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 pattern of the scaling group. Valid values:

  • NONE: disables health checks.

  • ECS: performs health checks on instances in the scaling group. Both ECS and ECI scaling groups use this value to enable instance health checks.

  • LOAD_BALANCER: determines the health status of instances based on the 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 instance launch template, which is used to specify that the scaling group obtains launch configuration information from the instance launch template.

lt-m5e3ofjr1zn1aw7****

LaunchTemplateVersion

string

No

The version of the instance launch template. Valid values:

  • A specific 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 out of the instances that exceed the minimum number of pay-as-you-go instances (OnDemandBaseCapacity) in the scaling group. 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 enable the supplemental spot instance feature. After this feature is enabled, when the scaling group receives a system message indicating that a spot instance will be reclaimed, the scaling group attempts to create a new instance to replace the spot instance to be reclaimed.

true

CompensateWithOnDemand

boolean

No

Specifies whether to allow Auto Scaling to automatically attempt to create pay-as-you-go instances to meet the required number of ECS instances if sufficient spot instances cannot be created due to price or inventory reasons when the MultiAZPolicy parameter in the CreateScalingGroup operation is set to COST_OPTIMIZED. Valid values:

  • true: allows Auto Scaling to create pay-as-you-go instances.

  • false: does not allow Auto Scaling to create pay-as-you-go instances.

true

SpotInstancePools

integer

No

The number of available instance types specified. The scaling group evenly creates spot instances based on the most cost-effective instance types. 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 ECI instances in the scaling group. The settings of this parameter enable the expected number of instances feature, and the scaling group automatically maintains the number of ECS instances or ECI instances at the expected number. Valid values: greater than or equal to the MinSize value and less than or equal to the MaxSize value.

Note

After a shutdown of the expected number of instances feature, if it is re-enabled, you must reset the DesiredCapacity value.

5

GroupDeletionProtection

boolean

No

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

  • true: enables deletion protection for the scaling group. In this case, the scaling group cannot be deleted.

  • false: disables deletion protection for the scaling group.

true

MultiAZPolicy

string

No

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

  • PRIORITY: scales ECS instances based on the priority of vSwitches (VSwitchIds.N). Auto Scaling preferentially attempts to scale instances in the zone where the vSwitch with the highest priority resides. If the scaling fails, Auto Scaling automatically attempts to scale instances in the zone where the vSwitch with the next highest priority resides.

  • 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. If the scaling configuration specifies multiple instance types and the billing method is set to preemptible, 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: evenly allocates ECS instances across the multiple zones specified in the scaling group. If the instances become unbalanced across zones due to insufficient inventory, you can call the RebalanceInstance operation to balance the resources.

  • COMPOSABLE: a composite policy that allows you to combine the preceding multi-zone scaling policies for ECS instances based on your needs.

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 VPC to which the specified vSwitches belong must be the same as the VPC to which the scaling group belongs.

The vSwitches can belong to multiple zones. The priorities of vSwitches are sorted in ascending order of numbers, where 1 indicates the highest priority. When ECS instances cannot be created in the zone where a vSwitch with a higher priority resides, the vSwitch with the next highest priority is automatically selected to create ECS instances.

vsw-bp1oo2a7isyrb8igf****

string

No

The ID of a vSwitch. N ranges from 1 to 5.

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

The vSwitches can belong to multiple zones. The priorities of vSwitches are sorted in ascending order of numbers, where 1 indicates the highest priority. When ECS instances cannot be created in the zone where a vSwitch with a higher priority resides, the vSwitch with the next highest priority is automatically selected to create ECS instances.

vsw-bp1oo2a7isyrb8igf****

LaunchTemplateOverride

array<object>

No

The launch template information.

object

No

The launch template information.

InstanceType

string

No

When you need the scaling group to scale based on the instance type capacity, specify both this parameter and LaunchTemplateOverride.N.WeightedCapacity.

This parameter is used to specify the instance type and 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. N ranges from 1 to 20.

Note

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

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

ecs.c5.xlarge

WeightedCapacity

integer

No

When you need the scaling group to scale based on the instance type capacity, specify this parameter after specifying LaunchTemplateOverride.N.InstanceType. The two parameters correspond to each other, and N must be consistent.

This parameter is used to specify the weight of the instance type, which indicates the capacity represented by a single instance of the instance type in the scaling group. A larger weight means fewer instances of this instance type are required to meet the expected capacity.

Because performance metrics such as the number of vCPUs and memory size vary among instance types, you can configure different weights for different instance types based on your needs.

Example:

  • Current capacity: 0.

  • Expected capacity: 6.

  • Capacity of the ecs.c5.xlarge instance type: 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 the maximum capacity (MaxSize) and the maximum weight of the instance type.

Valid values of WeightedCapacity: 1 to 500.

4

SpotPriceLimit

number

No

This parameter is used to specify the maximum bidding price for the instance type overridden by the launch template (namely, LaunchTemplateOverride.N.InstanceType). You can specify N values for this parameter to extend the launch template to support N instance types. N ranges from 1 to 20.

Note

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

0.025

AzBalance

boolean

No

Specifies whether the capacity of the scaling group is evenly distributed 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, which determines how the scaling group selects available instance types to meet the capacity. The capacity distribution strategy applies to both pay-as-you-go and spot capacities. This parameter takes effect 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 unit vCPU price of the instance types.

Default value: priority.

priority

SpotAllocationStrategy

string

No

The spot capacity distribution strategy. You can use this parameter to separately specify the distribution strategy for spot capacity. This parameter takes effect 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 unit vCPU price of the instance types.

Default value: priority.

lowestPrice

MaxInstanceLifetime

integer

No

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

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

Default value: null.

Note

This parameter cannot be set for ECI scaling groups or scaling groups with the no fees for stopped instances feature enabled.

86400

CustomPolicyARN

string

No

The ARN of the Function for the custom scale-in policy. This parameter takes effect only when the first removal 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 shutdown 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 change the settings of this parameter to true (namely, shutdown the expected number of instances feature) only when no scaling activity is in progress in the scaling group. The current DesiredCapacity property of the scaling group is also cleared, but the current number of instances in the scaling group remains unchanged.

false

ScalingPolicy

string

No

The revoke pattern of the scaling group. Valid values:

  • recycle: The revoke pattern of the scaling group is the shutdown and reclaim pattern.

  • release: The revoke pattern of the scaling group is the release pattern.

  • forcerelease: The revoke pattern of the scaling group is the forcible release pattern.

    Note

    If you select forcerelease, the system forcibly releases Running instances during scale-down activities. Forcibly 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 revoke pattern of the scaling group is the forcible shutdown and reclaim pattern.

    Note

    If you select forcerecycle, the system forcibly shuts down Running instances during scale-down activities. Forcible shutdown 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.

The ScalingPolicy parameter specifies the revoke pattern of the scaling group, but the specific action 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

HealthCheckTypes

array

No

The health check modes of the scaling group.

Note

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

string

No

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

  • NONE: disables health checks.

  • ECS: performs health checks on instances in the scaling group. Both ECS and ECI scaling groups use this value to enable instance health checks.

  • LOAD_BALANCER: determines the health status of instances based on the 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 be successfully stopped during the scale-in flow. Unit: seconds. Valid values: 30 to 240.

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

  • If the settings for this parameter are applied, the system waits for a maximum of the StopInstanceTimeout period for the instance to be successfully stopped. After the timeout period elapses, the scale-in flow continues regardless of whether the instance is successfully stopped.

  • If the settings for this parameter are not applied, the system waits for a long time for the instance to be successfully stopped. The scale-in flow continues only after the instance is successfully stopped. If the instance fails to be stopped, the scale-in flow will rollback and the scale-in failed.

  • Setting this parameter to 0 indicates that the parameter settings are canceled.

60

CapacityOptions

object

No

The capacity options.

OnDemandBaseCapacity

integer

No

The minimum number of pay-as-you-go instances required in the existing 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 out of the instances that exceed the minimum number of pay-as-you-go instances (OnDemandBaseCapacity) in the scaling group. 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 allow Auto Scaling to automatically attempt to create pay-as-you-go instances to meet the required number of ECS instances if sufficient spot instances cannot be created due to price or inventory reasons when the MultiAZPolicy parameter in the CreateScalingGroup operation is set to COST_OPTIMIZED. Valid values:

  • true: allows Auto Scaling to create pay-as-you-go instances.

  • false: does not allow Auto Scaling to create pay-as-you-go instances.

true

SpotAutoReplaceOnDemand

boolean

No

Specifies whether to attempt to use spot instances to replace pay-as-you-go capacity when CompensateWithOnDemand is enabled and the proportion of pay-as-you-go instances exceeds the OnDemandPercentageAboveBaseCapacity value. In common scenarios where CompensateWithOnDemand downgrades spot instances to pay-as-you-go instances due to spot inventory or price reasons, this feature attempts to use spot instances to replace the excess pay-as-you-go capacity to avoid long-term existence of pay-as-you-go instances. Valid values:

  • true: allows the replacement.

  • false: does not allow the replacement.

Default value: false.

true

PriceComparisonMode

string

No

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

  • PricePerUnit: compares prices based on the price per unit of capacity.

    The capacity of an instance in the scaling group is equal to the weight set for the instance type. The default weight is 1, which means one ECS instance occupies 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 parameter takes effect only when the zone balancing mode is enabled. Valid values:

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

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

Default value: BalancedBestEffort.

BalancedBestEffort

AutoRebalance

boolean

No

Specifies whether to enable automatic balancing for the scaling group. This parameter takes effect only when BalancedOnly is enabled for zone balancing in the scaling group. Valid values:

  • false: disables automatic balancing for the scaling group.

  • true: enables automatic balancing for the scaling group. When enabled, the scaling group automatically detects the capacity across zones. If the capacity is unbalanced, the scaling group proactively scales instances to rebalance the capacity across zones.

Default value: false.

false

ZoneShiftPolicy

object

No

The handling method for a stopped instance in the scaling group that fails to start during scale-out. Valid values:

  1. release (default): releases the instance that fails to start.

  2. retain: retains the instance that fails to start in the stopped state in the scaling group. The next scale-out activity will continue to attempt to start it. Note: Stopped instances are counted towards the MaxSize of the scaling group. If the capacity of stopped instances reaches MaxSize, the scale-out activity will not create new instances and will only attempt to start instances from the stopped state, which may cause continuous scale-out failures.

This parameter takes effect when ScalingPolicy is set to recycle or forcerecycle.

ScaleOutInHealthyZonesOnly

boolean

No

Specifies whether scale-out creates instances only in healthy zones during zone shift. Valid values:

  • true: creates instances only in healthy zones during scale-out (skips impaired zones).

  • false: does not restrict zones, and scale-out can create instances in any zone under the scaling group.

true

ScaleInBlockedRuleTypes

array

No

Blocks scale-in activities triggered by specified types of scaling rules (the blocking scope is all zones under the scaling group, not just the impaired zones) to prevent false scale-in caused by fake improvement of monitoring metrics due to unreachable instances in the impaired zone. Valid values:

  • StepScalingRule: blocks scale-in triggered by step scaling rules.

  • TargetTrackingScalingRule: blocks scale-in triggered by target tracking scaling rules.

  • None: does not block scale-in.

StepScalingRule

string

No

Blocks scale-in activities triggered by specified types of scaling rules (the blocking scope is all zones under the scaling group, not just the impaired zones) to prevent false scale-in caused by fake improvement of monitoring metrics due to unreachable instances in the impaired zone. Valid values:

  • StepScalingRule: blocks scale-in triggered by step scaling rules.

  • TargetTrackingScalingRule: blocks scale-in triggered by target tracking scaling rules.

  • None: does not block scale-in.

StepScalingRule

ImpairedZoneHealthCheckBehavior

string

No

The health check behavior in impaired zones. Valid values:

  • ReplaceUnhealthy: normally replaces unhealthy instances in all zones.

  • IgnoreUnhealthy: does not replace unhealthy instances in the impaired zone. Healthy zones are not affected.

ReplaceUnhealthy

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.