All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::ESS::ScalingGroup

Last Updated:Oct 23, 2023

ALIYUN::ESS::ScalingGroup is used to create a scaling group. A scaling group is a group of Elastic Compute Service (ECS) instances that are dynamically scaled based on the configured scenario. A scaling group does not immediately take effect after it is created. You must use ALIYUN::ESS::ScalingGroupEnable to enable the scaling group to trigger scaling activities and execute scaling rules.

Syntax

{
  "Type": "ALIYUN::ESS::ScalingGroup",
  "Properties": {
    "MultiAZPolicy": String,
    "DesiredCapacity": Integer,
    "NotificationConfigurations": List,
    "ProtectedInstances": List,
    "LaunchTemplateId": String,
    "LaunchTemplateVersion": String,
    "ScalingGroupName": String,
    "VSwitchIds": List,
    "DefaultCooldown": Integer,
    "MinSize": Integer,
    "GroupDeletionProtection": Boolean,
    "MaxSize": Integer,
    "InstanceId": String,
    "VSwitchId": String,
    "LoadBalancerIds": List,
    "StandbyInstances": List,
    "RemovalPolicys": List,
    "HealthCheckType": String,
    "DBInstanceIds": List,
    "Tags": List,
    "OnDemandPercentageAboveBaseCapacity": Integer,
    "CompensateWithOnDemand": Boolean,
    "ContainerGroupId": String,
    "ScalingPolicy": String,
    "SpotInstanceRemedy": Boolean,
    "SpotInstancePools": Integer,
    "OnDemandBaseCapacity": Integer,
    "GroupType": String,
    "LaunchTemplateOverrides": List,
    "AllocationStrategy": String,
    "AzBalance": Boolean,
    "MaxInstanceLifetime": Integer,
    "CustomPolicyARN": String,
    "SpotAllocationStrategy": String
  }
}

Properties

Property

Type

Required

Editable

Description

Constraint

MinSize

Integer

Yes

Yes

The minimum number of ECS instances in the scaling group.

Valid values: 0 to 1000.

When the number of ECS instances in the scaling group is less than the value of MinSize, Auto Scaling automatically creates ECS instances in the scaling group until the number of instances is equal to the value of this property.

MaxSize

Integer

Yes

Yes

The maximum number of ECS instances in the scaling group.

Valid values: 0 to 1000.

When the number of ECS instances in the scaling group is greater than the value of MaxSize, Auto Scaling automatically removes ECS instances from the scaling group until the number of instances is equal to the value of this property.

ScalingGroupName

String

No

Yes

The display name of the scaling group.

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

It must be unique within an Alibaba Cloud account in a region.

Default value: ScalingGroupId.

LaunchTemplateId

String

No

Yes

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

None.

LaunchTemplateVersion

String

No

Yes

The version of the launch template.

Valid values:

  • A fixed template version

  • Default: default template version

  • Latest: latest template version

RemovalPolicys

List

No

Yes

The policies that Auto Scaling uses to remove ECS instances from the scaling group.

Valid values:

  • OldestInstance (default): Auto Scaling removes the ECS instances that are added to the scaling group at the earliest point in time.

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

  • OldestScalingConfiguration (default): Auto Scaling removes ECS instances that are created based on the earliest scaling configuration.

VSwitchId

String

No

No

The vSwitch ID.

None.

LoadBalancerIds

List

No

Yes

The IDs of the Server Load Balancer (SLB) instances.

The value can be a JSON array that contains up to five SLB instance IDs. Separate multiple IDs with commas (,).

DefaultCooldown

Integer

No

Yes

The cooldown period of the scaling group after a scale-out or scale-in activity is complete.

Valid values: 0 to 86400.

Unit: seconds.

Default value: 300.

During the cooldown period, Auto Scaling executes only scaling activities that are triggered by event-triggered tasks of CloudMonitor.

DBInstanceIds

List

No

Yes

The IDs of the ApsaraDB RDS instances.

The value can be a JSON array that contains up to eight ApsaraDB RDS instance IDs. Separate multiple IDs with commas (,).

VSwitchIds

List

No

No

The IDs of the vSwitches.

You can specify up to five vSwitch IDs. If you specify this property, the VSwitchId property is ignored. The vSwitches are sorted in descending order of priority based on the sequence of the specified vSwitch IDs. If Auto Scaling fails to create ECS instances in the zone of the vSwitch that has the highest priority, Auto Scaling automatically creates ECS instances in the zone of the vSwitch that has the next highest priority.

MultiAZPolicy

String

No

Yes

The policy that Auto Scaling uses to scale ECS instances in a multi-zone scaling group.

Valid values:

  • PRIORITY: Auto Scaling scales ECS instances based on the specified vSwitches. If Auto Scaling fails to create ECS instances in the zone of the vSwitch that has the highest priority, Auto Scaling automatically creates ECS instances in the zone of the vSwitch that has the next highest priority.

  • BALANCE: Auto Scaling evenly distributes ECS instances across the specified zones of the scaling group.

  • COST_OPTIMIZED: Auto Scaling creates ECS instances based on the unit prices of the vCPUs in ascending order. If preemptible instance types are specified in the scaling configuration, Auto Scaling preferentially creates preemptible instances. If preemptible instances fail to be created due to issues such as insufficient resources, Auto Scaling automatically creates pay-as-you-go instances.

NotificationConfigurations

List

No

Yes

The notification configurations for event and resource changes.

For more information, see NotificationConfigurations properties.

ProtectedInstances

List

No

Yes

The number of protected ECS instances in the scaling group.

You can specify up to 1,000 instances.

StandbyInstances

List

No

Yes

The number of standby ECS instances in the scaling group.

You can specify up to 1,000 instances.

HealthCheckType

String

No

Yes

The type of the health check.

Valid values:

  • ECS

  • NONE

GroupDeletionProtection

Boolean

No

Yes

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 (default): disables deletion protection for the scaling group.

DesiredCapacity

Integer

No

Yes

The expected number of ECS instances in the scaling group. Auto Scaling automatically maintains the expected number of ECS instances in the scaling group.

The expected number must be greater than or equal to the value of MinSize and less than or equal to the value of MaxSize.

InstanceId

String

No

No

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

None.

Tags

List

No

Yes

The tags.

You can specify up to 20 tags.

For more information, see Tags properties.

OnDemandPercentageAboveBaseCapacity

Integer

No

Yes

The percentage of pay-as-you-go instances in the instances that exceed the number specified by OnDemandBaseCapacity.

OnDemandBaseCapacity specifies the minimum number of pay-as-you-go instances that must be contained in the scaling group.

Valid values: 0 to 100.

CompensateWithOnDemand

Boolean

No

Yes

Specifies whether to automatically create pay-as-you-go instances to reach the expected number of ECS instances in the scaling group.

You can use the property in the scenario in which MultiAZPolicy is set to COST_OPTIMIZED and the expected number of preemptible instances fail to be created due to reasons such as prices and insufficient resources.

Valid values:

  • true (default)

  • false

ContainerGroupId

String

No

No

The ID of the elastic container instance.

None.

ScalingPolicy

String

No

No

The reclaim mode of the scaling group.

Valid values:

  • recycle: economical mode

  • release: release mode

The ScalingPolicy property specifies the reclaim mode of the scaling group. The RemovePolicy parameter of the RemoveInstances operation specifies the action that is performed when instances are removed. For more information, see RemoveInstances.

SpotInstanceRemedy

Boolean

No

Yes

Specifies whether to supplement preemptible instances in the scaling group.

Valid values:

  • true: supplements preemptible instances in the scaling group.

    If you set this property to true, Auto Scaling attempts to create a preemptible instance to replace an existing preemptible instance when Auto Scaling receives a system message that indicates the existing preemptible instance is to be reclaimed.

  • false: does not supplement preemptible instances in the scaling group.

SpotInstancePools

Integer

No

Yes

The number of available instance types.

Auto Scaling evenly creates preemptible instances based on multiple instance types that have the lowest costs.

Valid values: 1 to 10.

OnDemandBaseCapacity

Integer

No

Yes

The minimum number of pay-as-you-go instances that must be contained in the scaling group.

Valid values: 0 to 1000.

If the number of pay-as-you-go instances is less than the value of this property, Auto Scaling preferentially creates pay-as-you-go instances.

GroupType

String

No

No

The type of the instances that are managed by the scaling group.

Valid values:

  • ECS (default): ECS instance

  • ECI: elastic container instance

LaunchTemplateOverrides

List

No

Yes

The information about the instance types that are specified by using the Extended Configurations feature of the launch template.

None.

AllocationStrategy

String

No

Yes

The allocation policy for instances.

This property determines the manner in which Auto Scaling selects instance types to create the required number of instances. You can apply the policy to pay-as-you-go instances and preemptible instances. This property takes effect only when MultiAZPolicy is set to COMPOSABLE.

Valid values:

  • priority (default): Auto Scaling creates instances based on the sequence of the specified instance types.

  • lowestPrice: Auto Scaling creates instances based on the instance types that have the lowest unit prices of vCPUs in ascending order.

AzBalance

Boolean

No

Yes

Specify whether to evenly distribute instances in the scaling group across zones.

This property takes effect only when MultiAZPolicy is set to COMPOSABLE.

Valid values:

  • true

  • false (default)

MaxInstanceLifetime

Integer

No

Yes

The maximum life span of an ECS instance in the scaling group.

Unit: seconds.

Valid values: 86400 to Integer.maxValue.

Default value: null.

CustomPolicyARN

String

No

Yes

The function Alibaba Cloud Resource Name (ARN) in the custom scale-in policy.

This property takes effect only when CustomPolicy is specified as the first policy in RemovalPolicies.

SpotAllocationStrategy

String

No

Yes

The allocation policy for preemptible instances.

You can use this property to separately specify the allocation policy for preemptible instances. This property takes effect only when MultiAZPolicy is set to COMPOSABLE.

Valid values:

  • priority (default): Auto Scaling creates instances based on the sequence of the specified instance types.

  • lowestPrice: Auto Scaling creates instances based on the instance types that have the lowest unit prices of vCPUs in ascending order.

NotificationConfigurations syntax

"NotificationConfigurations": [
  {
    "NotificationArn": String,
    "NotificationTypes": List
  }
]  

NotificationConfigurations properties

Property

Type

Required

Editable

Description

Constraint

NotificationArn

String

Yes

No

The ARN of the notification object that Auto Scaling uses to notify you when an instance is in the transition state for the lifecycle hook. The object can be a Message Service (MNS) queue or an MNS topic.

  • Value format for an MNS queue: acs:ess:{region}:{account-id}:queue/{queuename}.

  • Value format for an MNS topic: acs:ess:{region}:{account-id}:topic/{topicname}.

NotificationTypes

List

Yes

No

The types of notifications for Auto Scaling events and resource changes.

None.

Tags syntax

"Tags": [
  {
    "Key": String,
    "Value": String
  }
]  

Tags properties

Property

Type

Required

Editable

Description

Constraint

Key

String

Yes

No

The key of the tag.

The tag key must be 1 to 128 characters in length, and cannot contain http:// or https://. It cannot start with aliyun or acs:.

Value

String

No

No

The value of the tag.

The tag value can be up to 128 characters in length, and cannot contain http:// or https://. It cannot start with aliyun or acs:.

LaunchTemplateOverrides syntax

"LaunchTemplateOverrides": [
  {
    "InstanceType": String,
    "WeightedCapacity": Integer,
    "SpotPriceLimit": Number
  }
]  

LaunchTemplateOverrides properties

Property

Type

Required

Editable

Description

Constraint

InstanceType

String

No

Yes

The ECS instance type.

If you want to scale the scaling group based on the number of instance types, you must specify LaunchTemplateOverrides.InstanceType and LaunchTemplateOverrides.WeightedCapacity.

The ECS instance type that you specify overrides the instance type that is specified in the launch template.

Note

This property takes effect only when LaunchTemplateId is specified.

WeightedCapacity

Integer

No

Yes

The weight of the instance type.

If you want to scale the scaling group based on the number of instance types, you must specify LaunchTemplateOverrides.InstanceType before you specify LaunchTemplateOverrides.WeightedCapacity.

The weight indicates the capacity of an instance of the specified instance type in the scaling group. A higher weight indicates that a smaller number of instances of the specified instance type are required to meet the expected number requirement.

The performance metrics such as vCPUs and memory of each instance type are different. You can specify a different weight for each instance type based on your business requirements.

Sample code:

  • Current capacity: 0

  • Expected capacity: 6

  • Capacity of ecs.c5.xlarge: 4

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

Valid values of WeightedCapacity: 1 to 500.

Note

The number of instances in the scaling group during a scale-out activity cannot exceed the sum of the maximum number of instances that is specified by MaxSize and the maximum weight of the instance type.

SpotPriceLimit

Number

No

Yes

The maximum bid price.

This parameter specifies the maximum bid price for LaunchTemplateOverrides.InstanceType.

Note

This property takes effect only when LaunchTemplateId is specified.

Return values

Fn::GetAtt

  • ScalingGroupId: the ID of the scaling group.

  • ScalingGroupName: the name of the scaling group.

Examples

  • YAML format

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      VPC:
        AssociationProperty: ALIYUN::ECS::VPC::VPCId
        Type: String
        Label:
           
          en: Existing VPC Instance ID
      VSwitch:
        AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
        Type: String
        Label:
           
          en: VSwitch ID
        AssociationPropertyMetadata:
          VpcId: ${VPC}
      LaunchTemplateId:
        AssociationProperty: ALIYUN::ECS::LaunchTemplate::LaunchTemplateId
        Type: String
    Resources:
      ScalingGroup:
        Type: ALIYUN::ESS::ScalingGroup
        Properties:
          VpcId:
            Ref: VPC
          VSwitchId:
            Ref: VSwitch
          LaunchTemplateId:
            Ref: LaunchTemplateId
          MaxSize: 3
          ScalingGroupName: TestScalingGroup
          MinSize: 0
    Outputs:
      ScalingGroupId:
        Description: Scaling group Id
        Value:
          Fn::GetAtt:
            - ScalingGroup
            - ScalingGroupId
      ScalingGroupName:
        Description: Scaling group name
        Value:
          Fn::GetAtt:
            - ScalingGroup
            - ScalingGroupName
  • JSON format

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "VPC": {
          "AssociationProperty": "ALIYUN::ECS::VPC::VPCId",
          "Type": "String",
          "Label": {
             
            "en": "Existing VPC Instance ID"
          }
        },
        "VSwitch": {
          "AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
          "Type": "String",
          "Label": {
             
            "en": "VSwitch ID"
          },
          "AssociationPropertyMetadata": {
            "VpcId": "${VPC}"
          }
        },
        "LaunchTemplateId":{
          "AssociationProperty":"ALIYUN::ECS::LaunchTemplate::LaunchTemplateId",
          "Type":"String"
        }
      },
      "Resources": {
        "ScalingGroup": {
          "Type": "ALIYUN::ESS::ScalingGroup",
          "Properties": {
            "VpcId": {
              "Ref": "VPC"
            },
            "VSwitchId": {
              "Ref": "VSwitch"
            },
            "LaunchTemplateId": {
              "Ref": "LaunchTemplateId"
            },
            "MaxSize": 3,
            "ScalingGroupName": "TestScalingGroup",
            "MinSize": 0
          }
        }
      },
      "Outputs": {
        "ScalingGroupId": {
          "Description": "Scaling group Id",
          "Value": {
            "Fn::GetAtt": [
              "ScalingGroup",
              "ScalingGroupId"
            ]
          }
        },
        "ScalingGroupName": {
          "Description": "Scaling group name",
          "Value": {
            "Fn::GetAtt": [
              "ScalingGroup",
              "ScalingGroupName"
            ]
          }
        }
      }
    }

If you define only one scaling configuration that contains dependencies in a scaling group, you must specify the DependsOn property for the scaling group in the Resources section of a template. This way, the dependencies of the scaling configuration are associated with the scaling group.

In this example, the DependsOn property in ScalingGroup is set to SecurityGroup because SecurityGroup is the dependency of ScalingConfiguration.

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  VpcId:
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
    Type: String
  VSwitchId:
    AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
    Type: String
    AssociationPropertyMetadata:
      VpcId: ${VpcId}
Resources:
  ScalingGroupEnable:
    Type: ALIYUN::ESS::ScalingGroupEnable
    Properties:
      ScalingConfigurationId:
        Ref: ScalingConfiguration
      ScalingGroupId:
        Ref: ScalingGroup
      ScalingRuleArisExecuteVersion: 0
  SecurityGroup:
    Type: ALIYUN::ECS::SecurityGroup
    Properties:
      SecurityGroupName:
        Ref: ALIYUN::StackName
      VpcId:
        Ref: VpcId
      SecurityGroupIngress:
        - PortRange: '-1/-1'
          Priority: 1
          SourceCidrIp: 0.0.X.X/0
          IpProtocol: all
          NicType: internet
      SecurityGroupEgress:
        - PortRange: '-1/-1'
          Priority: 1
          IpProtocol: all
          DestCidrIp: 0.0.X.X/0
          NicType: internet
        - PortRange: '-1/-1'
          Priority: 1
          IpProtocol: all
          DestCidrIp: 0.0.X.X/0
          NicType: intranet
  ScalingConfiguration:
    Type: ALIYUN::ESS::ScalingConfiguration
    DependsOn: ScalingGroup
    Properties:
      InstanceType: ecs.g6e.large
      ImageId: centos_7_04_64_20G_alibase_201701015.vhd
      SystemDiskCategory: cloud_essd
      SystemDiskSize: 100
      ScalingConfigurationName:
        Ref: ALIYUN::StackName
      ScalingGroupId:
        Ref: ScalingGroup
      SecurityGroupId:
        Ref: SecurityGroup
  ScalingGroup:
    Type: ALIYUN::ESS::ScalingGroup
    DependsOn: SecurityGroup
    Properties:
      MaxSize: 3
      MinSize: 0
      DefaultCooldown: 15
      VpcId:
        Ref: VpcId
      VSwitchId:
        Ref: VSwitchId
Outputs: {}

For more examples, visit ScalingGroup.json and ScalingGroup.yml. In the examples, the following resource types are used: ALIYUN::ESS::ScalingGroup, ALIYUN::ESS::ScalingRule, ALIYUN::ESS::AlarmTask, ALIYUN::ESS::AlarmTaskEnable, ALIYUN::ESS::LifecycleHook, and ALIYUN::ESS::ScheduledTask.