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
}
}
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 the MinSize property, Auto Scaling automatically creates ECS instances 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 the MaxSize property, 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 (.). The name must start with a letter or digit.
The name must be unique to an Alibaba Cloud account within a region. Default value: ScalingGroupId. |
LaunchTemplateId | String | No | Yes | The ID of the launch template that is used by Auto Scaling to create instances. | None. |
LaunchTemplateVersion | String | No | Yes | The version of the instance launch template. | Valid values:
|
RemovalPolicys | List | No | Yes | The policies that are used to remove ECS instances from the scaling group. | Valid values:
|
VSwitchId | String | No | No | The ID of the vSwitch. | None. |
LoadBalancerIds | List | No | Yes | The ID of the Server Load Balancer (SLB) instance. | This value can be a JSON array that consists of up to five SLB instance IDs. Separate multiple IDs with commas (,). |
DefaultCooldown | Integer | No | Yes | The cooldown time after a scaling activity in which ECS instances are added to or removed from the scaling group. |
During the cooldown time, Auto Scaling executes only scaling activities that are triggered by CloudMonitor event-triggered tasks. |
DBInstanceIds | List | No | Yes | The IDs of ApsaraDB RDS instances. | This 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 vSwitches. | You can specify up to five vSwitch IDs. If you set this property, the VSwitchId property is ignored. vSwitches are sorted in descending order of priority. If Auto Scaling fails to create ECS instances in the zone of the vSwitch with the highest priority, Auto Scaling attempts to create ECS instances in the zone of the vSwitch with a lower priority. |
MultiAZPolicy | String | No | No | The ECS instance scaling policy for a multi-zone scaling group. | Valid values:
|
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. | Maximum value: 1000. |
StandbyInstances | List | No | Yes | The number of ECS instances that are in the standby state in the scaling group. | Maximum value: 1000. |
HealthCheckType | String | No | Yes | The type of health check. | Valid values:
|
GroupDeletionProtection | Boolean | No | Yes | Specifies whether to enable deletion protection for the scaling group. | Valid values:
|
DesiredCapacity | Integer | No | Yes | The expected number of ECS instances in the scaling group. Auto Scaling automatically maintains the specified number of ECS instances. | 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 configuration information and uses this information to create a scaling configuration. | None. |
Tags | List | No | Yes | The tags of the scaling group. | 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 among the excess instances that exceed the number specified by the OnDemandBaseCapacity property. |
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. | You can set this parameter to specify whether pay-as-you-go instances can be automatically
created to reach the expected number of ECS instances when the expected number of
preemptible instances is not reached. The expected number of preemptible instances
may not be reached due to reasons such as high costs and insufficient resources. This
property is valid only if the MultiAZPolicy property is set to COST_OPTIMIZED.
Valid values:
|
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:
This property specifies the reclaim modes of scaling groups, but the policy that is used to remove ECS instances from scaling groups is determined by the RemovePolicy property of the RemoveInstances operation. For more information, see RemoveInstances |
SpotInstanceRemedy | Boolean | No | Yes | Specifies whether to supplement preemptible instances. | Valid values:
|
SpotInstancePools | Integer | No | Yes | Specifies the number of instances of specific types. | Auto Scaling evenly creates preemptible instances based on multiple types of instances
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, pay-as-you-go instances are preferentially created. |
GroupType | String | No | No | The type of instances that are managed by the scaling group. | Valid values:
|
NotificationConfigurations syntax
"NotificationConfigurations": [
{
"NotificationArn": String,
"NotificationTypes": List
}
]
NotificationConfigurations properties
Property | Type | Required | Editable | Description | Constraint |
---|---|---|---|---|---|
NotificationArn | String | Yes | No | The Alibaba Cloud Resource Name (ARN) of the notification object that Auto Scaling uses to notify you when an instance is in the transition state for the lifecycle hook. This object can be a Message Service (MNS) queue or an MNS topic. | Format:
|
NotificationTypes | List | Yes | No | The types of notification configurations for ESS 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:// . The tag key cannot start with acs: or aliyun .
|
Value | String | No | No | The tag value. | The tag value must be 0 to 128 characters in length and cannot contain http:// or https:// . The tag value cannot start with acs: or aliyun .
|
Return values
Fn::GetAtt
- ScalingGroupId: the ID of the scaling group.
- ScalingGroupName: the name of the scaling group.
Examples
-
JSON
format{ "ROSTemplateFormatVersion": "2015-09-01", "Parameters": { "InstanceId": { "Type": "String", "Description": "The ID of the ECS instance from which the scaling group obtains configuration information of the specified instance." }, "VSwitchIds": { "Type": "CommaDelimitedList", "Description": "Parameter VSwitchIds.N is used to create instance in multiple zones. Parameter VSwitchIds.N has a priority over parameter VSwitchId.\nThe valid range of N is [1, 5], and you can specify at most 5 VSwitches in a VPC.\nThe priority of VSwitches descends from 1 to 5, and 1 indicates the highest priority.\nWhen you fail to create an instance in the zone to which a specified VSwitch belongs, another VSwitch with less priority replaces the specified one automatically.", "MinLength": 0, "MaxLength": 5 }, "NotificationConfigurations": { "Type": "Json", "Description": "When a scaling event occurs in a scaling group, ESS will send a notification to Cloud Monitor or MNS." }, "VSwitchId": { "Type": "String", "Description": "If you create a VPC scaling group, you must specify the ID of a VSwitch." }, "LoadBalancerIds": { "Type": "CommaDelimitedList", "Description": "ID list of a Server Load Balancer instance. A Json Array with format: [ \"lb-id0\", \"lb-id1\", ... \"lb-idz\" ], support up to 100 Load Balancer instance.", "MaxLength": 100 }, "DesiredCapacity": { "Type": "Number", "Description": "The expected number of ECS instances in a scaling group. The scaling group automatically keeps the number of ECS instances as expected. The number of ECS instances cannot be greater than the value of MaxSize and cannot be less than the value of MinSize." }, "GroupDeletionProtection": { "Type": "Boolean", "Description": "Whether to enable deletion protection for scaling group.\nDefault to False.", "AllowedValues": [ "True", "true", "False", "false" ], "Default": false }, "LaunchTemplateId": { "Type": "String", "Description": "The ID of the instance launch template from which the scaling group obtains launch configurations." }, "MaxSize": { "Type": "Number", "Description": "Maximum number of ECS instances in the scaling group. Value range: [0, 1000].", "MinValue": 0, "MaxValue": 1000 }, "ScalingGroupName": { "Type": "String", "Description": "Name shown for the scaling group, which must contain 2-40 characters (English or Chinese). The name must begin with a number, an upper/lower-case letter or a Chinese character and may contain numbers, \"_\", \"-\" or \".\". The account name is unique in the same region.\nIf this parameter is not specified, the default value is ScalingGroupId.", "AllowedPattern": "^[a-zA-Z0-9\\u4e00-\\u9fa5][-_.a-zA-Z0-9\\u4e00-\\u9fa5]{1,63}$" }, "MinSize": { "Type": "Number", "Description": "Minimum number of ECS instances in the scaling group. Value range: [0, 1000].", "MinValue": 0, "MaxValue": 1000 }, "DefaultCooldown": { "Type": "Number", "Description": "Default cool-down time (in seconds) of the scaling group. Value range: [0, 86400].\nThe default value is 300s.", "MinValue": 0, "MaxValue": 86400 }, "StandbyInstances": { "Type": "CommaDelimitedList", "Description": "ECS instances of standby mode in the scaling group.", "MaxLength": 1000 }, "LaunchTemplateVersion": { "Type": "String", "Description": "The version of the instance launch template. Valid values:\nA fixed template version numbe.\nDefault: The default template version is always used.\nLatest: The latest template version is always used." }, "MultiAZPolicy": { "Type": "String", "Description": "ECS scaling strategy for multi availability zone. Allow value:\n1. PRIORITY: scaling the capacity according to the virtual switch (VSwitchIds.N) you define. ECS instances are automatically created using the next priority virtual switch when the higher priority virtual switch cannot be created in the available zone.\n2. BALANCE: evenly allocate ECS instances between the multiple available zone specified by the scaling group.", "AllowedValues": [ "PRIORITY", "BALANCE" ] }, "RemovalPolicys": { "Type": "CommaDelimitedList", "AllowedValues": [ "OldestScalingConfiguration", "OldestInstance", "NewestInstance" ], "Description": "Policy for removing ECS instances from the scaling group.\nOptional values:\nOldestInstance: removes the first ECS instance attached to the scaling group.\nNewestInstance: removes the first ECS instance attached to the scaling group.\nOldestScalingConfiguration: removes the ECS instance with the oldest scaling configuration.\nDefault values: OldestScalingConfiguration and OldestInstance. You can enter up to two removal policies.", "MaxLength": 2 }, "ProtectedInstances": { "Type": "CommaDelimitedList", "Description": "ECS instances of protected mode in the scaling group.", "MaxLength": 1000 }, "DBInstanceIds": { "Type": "CommaDelimitedList", "Description": "ID list of an RDS instance. A Json Array with format: [ \"rm-id0\", \"rm-id1\", ... \"rm-idz\" ], support up to 100 RDS instance.", "MaxLength": 100 }, "Tags": { "Type": "Json", "Description": "Tags to attach to instance. Max support 20 tags to add during create instance. Each tag with two properties Key and Value, and Key is required.", "MaxLength": 20 }, "HealthCheckType": { "Type": "String", "Description": "The health check type. Allow values is \"ECS\" and \"NONE\", default to \"ECS\".", "AllowedValues": [ "ECS", "NONE" ] } }, "Resources": { "ScalingGroup": { "Type": "ALIYUN::ESS::ScalingGroup", "Properties": { "InstanceId": { "Ref": "InstanceId" }, "VSwitchIds": { "Ref": "VSwitchIds" }, "NotificationConfigurations": { "Ref": "NotificationConfigurations" }, "VSwitchId": { "Ref": "VSwitchId" }, "LoadBalancerIds": { "Ref": "LoadBalancerIds" }, "DesiredCapacity": { "Ref": "DesiredCapacity" }, "GroupDeletionProtection": { "Ref": "GroupDeletionProtection" }, "LaunchTemplateId": { "Ref": "LaunchTemplateId" }, "MaxSize": { "Ref": "MaxSize" }, "ScalingGroupName": { "Ref": "ScalingGroupName" }, "MinSize": { "Ref": "MinSize" }, "DefaultCooldown": { "Ref": "DefaultCooldown" }, "StandbyInstances": { "Ref": "StandbyInstances" }, "LaunchTemplateVersion": { "Ref": "LaunchTemplateVersion" }, "MultiAZPolicy": { "Ref": "MultiAZPolicy" }, "RemovalPolicys": { "Ref": "RemovalPolicys" }, "ProtectedInstances": { "Ref": "ProtectedInstances" }, "DBInstanceIds": { "Ref": "DBInstanceIds" }, "Tags": { "Ref": "Tags" }, "HealthCheckType": { "Ref": "HealthCheckType" } } } }, "Outputs": { "ScalingGroupId": { "Description": "Scaling group Id", "Value": { "Fn::GetAtt": [ "ScalingGroup", "ScalingGroupId" ] } }, "ScalingGroupName": { "Description": "Scaling group name", "Value": { "Fn::GetAtt": [ "ScalingGroup", "ScalingGroupName" ] } } } }
If you want to define only one scaling configuration that has a dependency for a scaling group, you must use the DependsOn property for the scaling group when you configure the Resources section of a template. The DependsOn property is used to associate the scaling configuration with the dependency in the template.
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
SystemDiskCategory:
Type: String
Default: cloud_essd
InstanceType:
Type: String
Default: ecs.g6e.large
ImageId:
Type: String
Default: centos_7_04_64_20G_alibase_201701015.vhd
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:
Ref: InstanceType
ImageId:
Ref: ImageId
SystemDiskCategory:
Ref: SystemDiskCategory
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.