All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::ESS::ScalingGroup

Last Updated:Sep 23, 2024

ALIYUN::ESS::ScalingGroup is used to create a scaling group. A scaling group can be 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 based on 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,
    "ServerGroups": List,
    "ResourceGroupId": 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. It 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 Auto Scaling uses to create instances in the scaling group.

None.

LaunchTemplateVersion

String

No

Yes

The version of the launch template for ECS instances.

Valid values:

  • Custom string: a fixed template version that you specify

  • Default: the default template version

  • Latest: the 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 earliest ECS instances added to the scaling group.

  • NewestInstance: Auto Scaling removes the most recent ECS instances added to the scaling group.

  • OldestScalingConfiguration (default): Auto Scaling removes the ECS instances created by the earliest scaling configuration.

VSwitchId

String

No

Yes

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 performed to add or remove ECS instances 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

Yes

The IDs of the vSwitches.

You can specify up to five vSwitch IDs. If you specify VSwitchIds, VSwitchId 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 the 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 health check type.

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 add 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 where 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 on instances when the instances are removed from the scaling group. For more information, see RemoveInstances.

SpotInstanceRemedy

Boolean

No

Yes

Specifies whether to supplement preemptible instances.

Valid values:

  • true: supplements preemptible instances.

    If you set this property to true, Auto Scaling creates an instance to replace a preemptible instance in the scaling group when Auto Scaling receives a system message indicating that the preemptible instance is to be reclaimed.

  • false: does not supplement preemptible instances.

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 you want to extend in 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 meet the capacity requirement. 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 instance in the scaling group.

Unit: seconds.

Valid values: 86400 to Integer.maxValue.

Default value: null.

CustomPolicyARN

String

No

Yes

The Alibaba Cloud Resource Name (ARN) of the function 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 the 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.

ServerGroups

List

No

No

The configurations of the SLB server groups.

For more information, see ServerGroups properties.

ResourceGroupId

String

No

Yes

The ID of the resource group.

None.

ServerGroups syntax

"ServerGroups": [
  {
    "Type": String,
    "ServerGroupId": String,
    "Weight": Number,
    "Port": Number
  }
]  

ServerGroups properties

Property

Type

Required

Editable

Description

Constraint

Type

String

Yes

No

The type of the SLB server group.

Valid values:

  • ALB: Application Load Balancer (ALB)

  • NLB: Network Load Balancer (NLB)

ServerGroupId

String

Yes

No

The ID of the SLB server group.

None.

Weight

Number

Yes

No

The weight of an ECS instance or elastic container instance that works as a backend server.

Valid values: 0 to 100.

A higher weight indicates that the ECS instance or elastic container instance receives more access requests. If you set Weight to 0, the ECS instance or elastic container instance does not receive access requests.

Port

Number

Yes

No

The port number of the ECS instance or elastic container instance.

Valid values: 1 to 65535.

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 Simple Message Queue (formerly MNS) queue or topic.

Value formats:

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

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

NotificationTypes

List

Yes

No

The notification types of 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 tag key.

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 tag value.

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 instances in the scaling group based on the weight of an instance type, you must specify this property and LaunchTemplateOverrides.WeightedCapacity.

The value of this property overrides the instance type that is specified in the launch template.

Note

LaunchTemplateOverrides.InstanceType takes effect only when LaunchTemplateId is specified.

WeightedCapacity

Integer

No

Yes

The weight of the instance type.

If you want to scale instances in the scaling group based on the weight of an instance type, you must specify LaunchTemplateOverrides.InstanceType before you specify LaunchTemplateOverrides.WeightedCapacity.

The weight specifies 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 is required to meet the expected capacity requirement.

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

Sample capacity configurations:

  • Current capacity: 0

  • Expected capacity: 6

  • Capacity of ecs.c5.xlarge: 4

To meet the expected capacity, the system adds two ecs.c5.xlarge instances to the scaling group.

Valid values of WeightedCapacity: 1 to 500.

Note

The capacity of 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 highest weight of an instance type.

SpotPriceLimit

Number

No

Yes

The maximum bidding price.

The maximum bidding price for the ECS instance type specified by 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 DependsOn 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, DependsOn 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: {}