ALIYUN::ESS::ScalingConfiguration

Updated at:

The ALIYUN::ESS::ScalingConfiguration resource type creates a scaling configuration for a scaling group.

Syntax

{
  "Type": "ALIYUN::ESS::ScalingConfiguration",
  "Properties": {
    "PasswordInherit": Boolean,
    "DiskMappings": List,
    "RamRoleName": String,
    "IoOptimized": String,
    "InternetChargeType": String,
    "KeyPairName": String,
    "InstanceId": String,
    "InstanceTypes": List,
    "ImageId": String,
    "ResourceGroupId": String,
    "SpotStrategy": String,
    "InstanceType": String,
    "SystemDiskCategory": String,
    "SystemDiskSize": Integer,
    "SystemDiskAutoSnapshotPolicyId": String,
    "SystemDiskPerformanceLevel": String,
    "InternetMaxBandwidthOut": Integer,
    "InstanceName": String,
    "InternetMaxBandwidthIn": Integer,
    "ScalingConfigurationName": String,
    "UserData": String,
    "DeploymentSetId": String,
    "SecurityGroupId": String,
    "SpotPriceLimit": Number,
    "HpcClusterId": String,
    "ScalingGroupId": String,
    "SpotPriceLimitForInstanceType": Map,
    "TagList": List,
    "Ipv6AddressCount": Integer,
    "LoadBalancerWeight": Integer,
    "CreditSpecification": String,
    "ImageFamily": String,
    "CpuOptions": Map,
    "HostName": String,
    "Password": String,
    "SystemDiskBurstingEnabled": Boolean,
    "ImageOptionsLoginAsNonRoot": Boolean,
    "SystemDiskEncrypted": Boolean,
    "SystemDiskEncryptAlgorithm": String,
    "ZoneId": String,
    "Cpu": Integer,
    "SystemDiskProvisionedIops": Integer,
    "SystemDiskKMSKeyId": String,
    "InstancePatternInfos": List,
    "SpotInterruptionBehavior": String,
    "ImageName": String,
    "SystemDiskDescription": String,
    "SystemDiskDiskName": String,
    "InstanceTypeOverrides": List,
    "SystemDiskCategories": List,
    "Memory": Integer,
    "InstanceDescription": String,
    "SecurityGroupIds": List,
    "SpotDuration": Integer,
    "SecurityEnhancementStrategy": String,
    "Affinity": String,
    "Tenancy": String,
    "PrivatePoolOptions": Map,
    "DedicatedHostId": String
  }
}

Properties

Property

Type

Required

Editable

Description

Constraints

ScalingGroupId

String

Yes

No

The ID of the scaling group to which the scaling configuration belongs.

None.

Affinity

String

No

Yes

Specifies whether the dedicated host instance is associated with a dedicated host.

Valid values:

  • default: The instance is not associated with a dedicated host. If an instance with the economical shutdown mode enabled is restarted and the original dedicated host lacks available resources, the instance is placed on another dedicated host in the automatic deployment resource pool.

  • host: The instance is associated with a dedicated host. If an instance with the economical shutdown mode enabled is restarted, it remains on the original dedicated host. The restart fails if the original dedicated host lacks available resources.

Cpu

Integer

No

Yes

The number of vCPUs.

You can specify Cpu and Memory together to define an instance type range. For example, Cpu=2 and Memory=16 define all instance types with 2 vCPUs and 16 GiB of memory. Auto Scaling determines the available instance types based on I/O optimization, zones, and other factors, and creates the lowest-priced instance.

CpuOptions

Map

No

Yes

CPU options.

For more information, see CpuOptions properties.

CreditSpecification

String

No

Yes

The operating mode of burstable instances.

Valid values:

  • Unlimited (default): Unlimited mode.

  • Standard: Standard mode.

For more information about instance performance, see Burstable instances.

DedicatedHostId

String

No

Yes

Specifies whether to create ECS instances on a dedicated host.

Dedicated hosts do not support preemptible instances. If you specify DedicatedHostId, SpotStrategy and SpotPriceLimit are ignored. Call DescribeDedicatedHosts to query dedicated host IDs.

DeploymentSetId

String

No

No

The deployment set ID.

None.

DiskMappings

List

No

Yes

The disks to attach.

A maximum of 16 disks is supported. For more information, see DiskMappings properties.

HostName

String

No

Yes

The hostname of the cloud server.

A period (.) or hyphen (-) cannot be the first or last character, and periods or hyphens cannot be consecutive. Naming requirements for different instance types are as follows:

  • Windows instances: The hostname must contain 2 to 15 characters and can contain uppercase letters, lowercase letters, digits, and hyphens (-). It cannot contain periods (.) or consist entirely of digits.

  • Other instance types, such as Linux: The hostname must contain 2 to 64 characters and can contain multiple periods (.). Each segment between two periods (.) can contain uppercase letters, lowercase letters, digits, and hyphens (-).

HpcClusterId

String

No

No

The ID of the E-HPC cluster to which the instance belongs.

None.

ImageFamily

String

No

Yes

The image family name.

Set this property to obtain the latest available image in the image family for instance creation. You cannot set this property if ImageId is set.

ImageId

String

No

Yes

The image ID of the instance, including public images, custom images, and Alibaba Cloud Marketplace images.

For more information, see Public images.

ImageName

String

No

Yes

The image file name.

None.

ImageOptionsLoginAsNonRoot

Boolean

No

No

Specifies whether an ECS instance uses the ecs-user account to log on.

Valid values:

  • true: Yes.

  • false: No.

InstanceDescription

String

No

Yes

The description of the ECS instance.

The description must contain 2 to 256 English or Chinese characters and cannot start with http:// or https://.

InstanceId

String

No

No

The instance ID of the scaling configuration.

None.

InstanceName

String

No

Yes

The name of instances created based on the current scaling configuration.

None.

InstancePatternInfos

List

No

Yes

The information set for intelligent configuration.

For more information, see InstancePatternInfos properties.

InstanceType

String

No

Yes

The instance type.

For more information, see Instance family overview.

InstanceTypeOverrides

List

No

Yes

The information about the specified instance types.

For more information, see InstanceTypeOverrides properties.

InstanceTypes

List

No

Yes

The multiple-instance-type parameter.

If InstanceTypes is specified, InstanceType does not take effect. You can configure up to 10 instance types in one scaling configuration. Their priorities decrease in the order of the list elements. If an instance cannot be created with a higher-priority instance type, Auto Scaling automatically selects the next lower-priority instance type.

InternetChargeType

String

No

Yes

The billing method for public network access bandwidth.

Valid values:

  • PayByBandwidth: Billed by fixed bandwidth.

  • PayByTraffic (default): Billed by traffic.

InternetMaxBandwidthIn

Integer

No

No

The maximum inbound public bandwidth.

Unit: Mbps.

Valid values: 1 to 200.

If you do not specify this property, inbound bandwidth is automatically set to 200 Mbps. Inbound data traffic is free of charge and this property never incurs charges.

InternetMaxBandwidthOut

Integer

No

Yes

The maximum outbound public bandwidth.

Valid values:

  • Fixed-bandwidth billing: 0 to 100. Default value: 0.

  • Traffic-based billing: 0 to 100. This property is required.

Unit: Mbps.

IoOptimized

String

No

Yes

Specifies whether to create an I/O optimized instance.

Valid values:

  • none (default): Non-I/O optimized.

  • optimized: I/O optimized.

Ipv6AddressCount

Integer

No

Yes

The number of randomly generated IPv6 addresses to assign to the elastic network interface.

None.

KeyPairName

String

No

Yes

The name of the key pair bound to the instance.

  • If the instance type is Windows, this property is ignored and its default value is empty.

  • If the instance type is Linux, password logon is initialized as disabled.

LoadBalancerWeight

Integer

No

Yes

The weight of the ECS instance when it is a load balancing backend server.

Valid values: 1 to 100. Default value: 50.

Memory

Integer

No

Yes

The memory size.

Unit: GiB. You can specify Cpu and Memory together to define an instance type range. For example, Cpu=2 and Memory=16 define all instance types with 2 vCPUs and 16 GiB of memory. Auto Scaling determines the available instance types based on I/O optimization, zones, and other factors, and creates the lowest-priced instance.

Password

String

No

Yes

The password of the ECS instance.

The password must contain 8 to 30 characters and must include three character categories: uppercase letters, lowercase letters, digits, and special characters. The following special characters are supported:

()` ~!@#$%^&*-_+=\|{}[]:;'<>,.?/

A password for a Windows instance cannot start with a forward slash (/).

Note

If you specify Password, use HTTPS to send requests to prevent password disclosure.

PasswordInherit

Boolean

No

Yes

Specifies whether to use the password preset in the image.

If the image preset password is used, make sure that the image has a preset password.

PrivatePoolOptions

Map

No

Yes

The private pool configuration for starting instances.

For more information, see PrivatePoolOptions properties.

RamRoleName

String

No

Yes

The RAM role name of the instance.

Use the RAM API ListRoles to query the RAM role name. For more information, see CreateRole and ListRoles.

ResourceGroupId

String

No

Yes

The ID of the resource group to which the instance belongs.

None.

ScalingConfigurationName

String

No

Yes

The name of the scaling configuration.

The name must contain 2 to 64 characters, start with a digit, English letter, or Chinese character, and can contain digits, English letters, Chinese characters, underscores (_), hyphens (-), and periods (.).

The name must be unique within a scaling group in the same region.

If you do not specify this property, the scaling configuration ID is used by default.

SecurityEnhancementStrategy

String

No

No

Specifies whether to enable security hardening.

Valid values:

  • Active: Enables security hardening and applies only to public images.

  • Deactive: Does not enable security hardening and applies to all image types.

SecurityGroupId

String

No

Yes

The security group to which the instance belongs.

None.

SecurityGroupIds

List

No

Yes

Adds the ECS instance to multiple security groups.

Note

SecurityGroupId and SecurityGroupIds cannot be specified at the same time.

SpotDuration

Integer

No

Yes

The retention period of a preemptible instance.

Unit: hours. Valid values:

  • 1: Alibaba Cloud guarantees that the instance is not automatically released for one hour after creation. After one hour, the system compares the bid with the market price and checks resource inventory to determine whether to retain or reclaim the instance.

  • 0: Alibaba Cloud does not guarantee that the instance runs for one hour after creation. The system compares the bid with the market price and checks resource inventory to determine whether to retain or reclaim the instance.

SpotInterruptionBehavior

String

No

Yes

The interruption behavior of a preemptible instance.

None.

SpotPriceLimit

Number

No

Yes

The maximum hourly price of the instance.

Up to three decimal places are supported.

This property takes effect when SpotStrategy is set to SpotWithPriceLimit. Its value is overridden by SpotPriceLimitForInstanceType.

SpotPriceLimitForInstanceType

Map

No

Yes

The instance types and corresponding bids for preemptible instances.

Format: {"<instance_type_1>": <price_limit_1>, ..., {"<instance_type_10>": <price_limit_10>}.

This property takes effect when SpotStrategy is set to SpotWithPriceLimit.

You can configure up to 10 instance-and-price pairs.

SpotStrategy

String

No

Yes

The preemptible strategy of a pay-as-you-go instance.

Valid values:

  • NoSpot (default): A normal pay-as-you-go instance.

  • SpotWithPriceLimit: A preemptible instance with a price limit.

  • SpotAsPriceGo: The system automatically bids according to the current market price.

SystemDiskAutoSnapshotPolicyId

String

No

Yes

The automatic snapshot policy ID used by the system disk.

None.

SystemDiskBurstingEnabled

Boolean

No

No

Specifies whether to enable burst performance for the system disk.

Valid values:

  • true: Enabled.

  • false: Disabled.

SystemDiskCategories

List

No

Yes

The multiple disk categories for the system disk.

If a higher-priority disk category is unavailable, Auto Scaling automatically attempts to create the system disk with the next lower-priority category. Valid values:

  • cloud: Basic disk.

  • cloud_efficiency: Ultra disk.

  • cloud_ssd: Standard SSD.

  • cloud_essd: ESSD.

SystemDiskCategory

String

No

Yes

The system disk category.

Valid values:

  • cloud: Basic disk.

  • cloud_efficiency: Ultra disk.

  • cloud_ssd: Standard SSD.

  • ephemeral_ssd: Local SSD.

  • cloud_essd: ESSD.

When InstanceType is an I-series instance type and the instance is not I/O optimized, the default value is cloud. Otherwise, the default value is cloud_efficiency.

SystemDiskDescription

String

No

Yes

The description of the system disk.

None.

SystemDiskDiskName

String

No

Yes

The name of the system disk.

None.

SystemDiskEncryptAlgorithm

String

No

Yes

The encryption algorithm used by the system disk.

Valid values:

  • AES-256.

  • SM4-128.

SystemDiskEncrypted

Boolean

No

Yes

Specifies whether the system disk is encrypted.

Valid values:

  • true: Encrypted.

  • false: Not encrypted.

SystemDiskKMSKeyId

String

No

Yes

The KMS key ID used by the system disk.

None.

SystemDiskPerformanceLevel

String

No

Yes

The performance level of an ESSD used as the system disk.

Valid values:

  • PL1 (default): A maximum of 50,000 random read/write IOPS per disk.

  • PL2: A maximum of 100,000 random read/write IOPS per disk.

  • PL3: A maximum of 1,000,000 random read/write IOPS per disk.

For information about selecting an ESSD performance level, see ESSDs.

SystemDiskProvisionedIops

Integer

No

Yes

The provisioned IOPS (Input/Output Operations Per Second) performance metric of the system disk.

None.

SystemDiskSize

Integer

No

Yes

The system disk size.

Valid values: 20 to 500.

Default value: 40.

Unit: GiB.

If a custom image is used to create the system disk, the system disk size must be greater than or equal to the custom image size.

TagList

List

No

Yes

The instance tags.

Tags are passed as key-value pairs. You can use up to five tags in the following format: {"key1": "value1", "key2": "value2", ... "key5": "value5"}.

For more information, see TagList properties.

Tenancy

String

No

Yes

Specifies whether to create an instance on a dedicated host.

Valid values:

  • default: Creates a non-dedicated-host instance.

  • host: Creates a dedicated-host instance. If DedicatedHostId is not specified, Alibaba Cloud automatically selects a dedicated host for the instance.

UserData

String

No

Yes

The user data passed when an instance is created.

The content must be no more than 16 KB. Base64 encoding is not required. Escape special characters with a backslash (\).

ZoneId

String

No

Yes

The zone ID to which the instance belongs.

None.

DiskMappings syntax

"DiskMappings": [
  {
    "Category": String,
    "DiskName": String,
    "Description": String,
    "AutoSnapshotPolicyId": String,
    "PerformanceLevel": String,
    "Encrypted": String,
    "KMSKeyId": String,
    "Device": String,
    "SnapshotId": String,
    "Size": String,
    "DeleteWithInstance": Boolean,
    "ProvisionedIops": Integer,
    "Categories": List,
    "BurstingEnabled": Boolean
  }
]

DiskMappings properties

Property

Type

Required

Editable

Description

Constraints

AutoSnapshotPolicyId

String

No

No

The automatic snapshot policy ID used by the data disk.

None.

BurstingEnabled

Boolean

No

No

Specifies whether to enable burst performance for the data disk.

Valid values:

  • true: Enabled.

  • false: Disabled.

Categories

List

No

No

The multiple disk categories for the data disk.

The first disk category has the highest priority, and the other disk categories have decreasing priority. If a higher-priority disk category is unavailable, Auto Scaling automatically attempts to create the data disk with the next lower-priority category. Valid values:

  • cloud: Basic disk. The DeleteWithInstance property of a basic disk created with an instance is true.

  • cloud_efficiency: Ultra disk.

  • cloud_ssd: Standard SSD.

  • cloud_essd: ESSD.

Category

String

No

No

The data disk category.

Valid values:

  • cloud: Basic disk.

  • cloud_efficiency (default): Ultra disk.

  • cloud_ssd: Standard SSD.

  • ephemeral_ssd: Local SSD.

  • cloud_essd: ESSD. For I/O optimized instances, the default value is cloud_efficiency. For non-I/O optimized instances, the default value is cloud.

DeleteWithInstance

Boolean

No

No

Specifies whether the data disk is released with the instance.

Valid values:

  • true: The disk is released when the instance is released.

  • false: The disk is retained when the instance is released.

Description

String

No

No

The data disk description.

The length must be 2 to 256 characters. It cannot start with http:// or https://.

Device

String

No

No

The mount point of the data disk.

If this property is not specified, the system assigns it when ECS instances are automatically created. Values start from /dev/xvdb and end at /dev/xvdz.

DiskName

String

No

No

The data disk name.

The length must be 2 to 128 characters. It must start with an English letter or Chinese character and cannot start with http:// or https://. It can contain digits, English letters, Chinese characters, colons (:), underscores (_), and hyphens (-).

Encrypted

String

No

No

Specifies whether the data disk is encrypted.

Valid values:

  • true: Encrypted.

  • false (default): Not encrypted.

KMSKeyId

String

No

No

The KMS key ID for the data disk.

None.

PerformanceLevel

String

No

No

The performance level of an ESSD used as the data disk.

Valid values:

  • PL1 (default): A maximum of 50,000 random read/write IOPS per disk.

  • PL2: A maximum of 100,000 random read/write IOPS per disk.

  • PL3: A maximum of 1,000,000 random read/write IOPS per disk.

For information about selecting an ESSD performance level, see ESSDs.

ProvisionedIops

Integer

No

No

The provisioned IOPS (Input/Output Operations Per Second) performance metric of the data disk.

Note

IOPS is the number of I/O operations that can be processed per second and indicates the block storage read/write capability. Unit: operations.

Size

String

No

No

The size of the data disk.

Valid values:

  • cloud: 5 to 2,000.

  • cloud_efficiency: 20 to 32,768.

  • cloud_ssd: 20 to 32,768.

  • cloud_essd: 20 to 32,768.

  • ephemeral_ssd: 5 to 800.

Unit: GB.

After this property is specified, the disk size must be greater than or equal to the snapshot size specified by SnapshotId.

SnapshotId

String

No

No

The snapshot used to create the data disk.

After this property is specified, Size is ignored and the actual disk size is the size of the specified snapshot. If the snapshot was created on or before July 15, 2013, the call is rejected and InvalidSnapshot.TooOld is displayed in the response parameters.

PrivatePoolOptions syntax

"PrivatePoolOptions": 
  {
    "MatchCriteria": String,
    "Id": String
  }

PrivatePoolOptions properties

Property

Type

Required

Editable

Description

Constraints

Id

String

No

Yes

The private pool ID.

The ID of an elasticity assurance or capacity reservation service.

MatchCriteria

String

No

Yes

The private pool capacity option for starting instances.

An elasticity assurance or capacity reservation service generates private pool capacity after it takes effect for instance startup. Valid values:

  • Open: Open mode. Automatically matches open private pool capacity. If no matching private pool capacity exists, public pool resources are used to start the instance. PrivatePoolOptions.Id is not required in this mode.

  • Target: Target mode. Starts the instance using the specified private pool capacity. If the private pool capacity is unavailable, instance startup fails. PrivatePoolOptions.Id is required in this mode.

  • None: No-use mode. Private pool capacity is not used to start the instance.

InstanceTypeOverrides syntax

"InstanceTypeOverrides": [
  {
    "InstanceType": String,
    "WeightedCapacity": Integer
  }
]

InstanceTypeOverrides properties

Property

Type

Required

Editable

Description

Constraints

InstanceType

String

No

Yes

The specified instance type.

To scale the scaling group by instance type capacity, specify this property and WeightedCapacity together.

WeightedCapacity

Integer

No

Yes

The weight of the specified instance type.

The vCPU count, memory size, and other performance metrics can vary by instance type. You can configure different weights for different instance types as needed. For example:

  • Current capacity: 0.

  • Desired capacity: 6.

  • The capacity of ecs.c5.xlarge: 4.

To meet the desired capacity, the scaling group adds two ecs.c5.xlarge instances.

InstancePatternInfos syntax

"InstancePatternInfos": [
  {
    "BurstablePerformance": String,
    "Architectures": List,
    "InstanceFamilyLevel": String,
    "Memory": Number,
    "MaxPrice": Number,
    "ExcludedInstanceTypes": List,
    "Cores": Integer
  }
]

InstancePatternInfos properties

Property

Type

Required

Editable

Description

Constraints

Architectures

List

No

Yes

The architecture type of the instance type.

Valid values:

  • X86: X86 computing.

  • Heterogeneous: Heterogeneous computing, such as GPU or FPGA.

  • BareMental: Elastic Compute Service Bare Metal Instance.

  • Arm: Arm computing.

Default: All architecture types.

BurstablePerformance

String

No

No

Specifies whether the instance type is burstable.

Valid values:

  • Exclude: Excludes burstable instance types.

  • Include: Includes burstable instance types.

  • Required: Includes only burstable instance types.

Default value: Include.

Cores

Integer

No

Yes

The vCPU core count of the instance type in intelligent configuration mode.

Used to filter instance type ranges that meet requirements. For more information, see Instance family overview. Note the following:

  • InstancePatternInfos applies only when the scaling group network type is VPC.

  • Configure InstancePatternInfos.Cores and InstancePatternInfos.Memory together.

  • If InstanceType or InstanceTypes specifies an instance type, Auto Scaling preferentially uses the specified instance type to scale out. If that instance type is out of stock, it preferentially uses the lowest-priced instance type that meets InstancePatternInfos parameter values.

ExcludedInstanceTypes

List

No

Yes

The instance types to exclude.

Wildcards () can exclude an individual instance type or an entire instance family. For example:

  • ecs.c6.large: Excludes the ecs.c6.large instance type.

  • ecs.c6.: Excludes the entire c6 instance family.

InstanceFamilyLevel

String

No

Yes

The instance family level.

Used to filter instance type ranges that meet requirements and takes effect when CostOptimization is enabled. Valid values:

  • EntryLevel: Entry level, that is, shared instance types. It costs less but does not guarantee stable compute performance. It is suitable for busines scenarios with low CPU utilization. For more information, see Shared instance families.

  • EnterpriseLevel: Enterprise level. It provides stable performance and exclusive resources and is suitable for business scenarios that require high stability. For more information, see Instance family overview.

  • CreditEntryLevel: Credit entry level, that is, burstable instance types. CPU credits ensure compute performance and are suitable for business scenarios with low usual CPU utilization and occasional CPU bursts. For more information, see Burstable instances.

MaxPrice

Number

No

Yes

The maximum acceptable hourly price for pay-as-you-go or preemptible instances in intelligent configuration mode.

None.

Memory

Number

No

Yes

The memory size of the instance type in intelligent configuration mode.

Unit: GiB.

Used to filter instance type ranges that meet requirements.

CpuOptions syntax

"CpuOptions": 
  {
    "NestedVirtualization": String
  }

CpuOptions properties

Property

Type

Required

Editable

Description

Constraints

NestedVirtualization

String

No

Yes

Specifies whether to enable nested virtualization.

Valid values:

  • enabled: Enables nested virtualization.

  • disabled: Disables nested virtualization.

TagList syntax

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

TagList properties

Property

Type

Required

Editable

Description

Constraints

Key

String

Yes

No

The tag key.

The length must be 1 to 64 characters. It cannot start with aliyun or acs: and cannot contain http:// or https://.

Value

String

No

No

The tag value.

The length must be 0 to 128 characters. It cannot start with aliyun or acs: and cannot contain http:// or https://.

Return values

Fn::GetAtt

  • ScalingConfigurationId: The scaling configuration ID. Generated by the system and globally unique.

  • ScalingGroupId: The ID of the scaling group to which the scaling configuration belongs.

Examples

Scenario 1: Create a scaling configuration for an existing scaling group.

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: "\u4e3a\u5df2\u6709\u4f38\u7f29\u7ec4\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u4f38\u7f29\u914d\u7f6e\uff0c\u6307\u5b9a\u5b9e\u4f8b\u89c4\u683c\u3001\u955c\u50cf\u548c\u5b89\u5168\u7ec4\u3002"
  en: Create a simple scaling configuration for an existing scaling group with specified instance type, image, and security group.
Parameters:
  AutoScalingGroupId:
    Type: String
    Label:
      zh-cn: "\u4f38\u7f29\u7ec4ID"
      en: Scaling Group ID
    Description:
      zh-cn: "\u9009\u62e9\u5df2\u521b\u5efa\u7684\u4f38\u7f29\u7ec4ID\u3002"
      en: Select an existing scaling group ID.
    AssociationProperty: ALIYUN::ESS::AutoScalingGroup::AutoScalingGroupId
  SecurityGroupId:
    Type: String
    Label:
      zh-cn: "\u5b89\u5168\u7ec4ID"
      en: Security Group ID
    Description:
      zh-cn: "\u9009\u62e9\u5b89\u5168\u7ec4ID\u3002"
      en: Select a security group ID.
    AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
  ImageId:
    Type: String
    Label:
      zh-cn: "\u955c\u50cfID"
      en: Image ID
    Description:
      zh-cn: "\u9009\u62e9\u7528\u4e8e\u521b\u5efa\u5b9e\u4f8b\u7684\u955c\u50cf\u3002"
      en: Select an image for creating instances.
    AssociationProperty: ALIYUN::ECS::Image::ImageId
    AssociationPropertyMetadata:
      SupportedImageOwnerAlias:
        - system
        - self
        - others
  InstanceType:
    Type: String
    Label:
      zh-cn: "\u5b9e\u4f8b\u89c4\u683c"
      en: Instance Type
    Description:
      zh-cn: "\u9009\u62e9ECS\u5b9e\u4f8b\u89c4\u683c\u3002"
      en: Select an ECS instance type.
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      InstanceChargeType: PostPaid
  SystemDiskCategory:
    Type: String
    Label:
      zh-cn: "\u7cfb\u7edf\u76d8\u7c7b\u578b"
      en: System Disk Category
    Description:
      zh-cn: "\u9009\u62e9\u7cfb\u7edf\u76d8\u7c7b\u578b\u3002"
      en: Select a system disk category.
    AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
    AssociationPropertyMetadata:
      InstanceType: ${InstanceType}
    Default: cloud_essd
Resources:
  ScalingConfiguration:
    Type: ALIYUN::ESS::ScalingConfiguration
    Properties:
      ScalingGroupId:
        Ref: AutoScalingGroupId
      SecurityGroupId:
        Ref: SecurityGroupId
      ImageId:
        Ref: ImageId
      InstanceType:
        Ref: InstanceType
      SystemDiskCategory:
        Ref: SystemDiskCategory
      SystemDiskSize: 40
      ScalingConfigurationName:
        Ref: ALIYUN::StackName
      InternetMaxBandwidthOut: 5
      InternetChargeType: PayByTraffic
Outputs:
  ScalingConfigurationId:
    Description:
      zh-cn: "\u4f38\u7f29\u914d\u7f6eID\u3002"
      en: Scaling configuration ID.
    Label:
      zh-cn: "\u4f38\u7f29\u914d\u7f6eID"
      en: Scaling Configuration ID
    Value:
      Fn::GetAtt:
        - ScalingConfiguration
        - ScalingConfigurationId
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - AutoScalingGroupId
          - SecurityGroupId
          - ImageId
          - InstanceType
          - SystemDiskCategory
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "\u4e3a\u5df2\u6709\u4f38\u7f29\u7ec4\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u4f38\u7f29\u914d\u7f6e,\u6307\u5b9a\u5b9e\u4f8b\u89c4\u683c、\u955c\u50cf\u548c\u5b89\u5168\u7ec4。",
    "en": "Create a simple scaling configuration for an existing scaling group with specified instance type, image, and security group."
  },
  "Parameters": {
    "AutoScalingGroupId": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u4f38\u7f29\u7ec4ID",
        "en": "Scaling Group ID"
      },
      "Description": {
        "zh-cn": "\u9009\u62e9\u5df2\u521b\u5efa\u7684\u4f38\u7f29\u7ec4ID。",
        "en": "Select an existing scaling group ID."
      },
      "AssociationProperty": "ALIYUN::ESS::AutoScalingGroup::AutoScalingGroupId"
    },
    "SecurityGroupId": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u5b89\u5168\u7ec4ID",
        "en": "Security Group ID"
      },
      "Description": {
        "zh-cn": "\u9009\u62e9\u5b89\u5168\u7ec4ID。",
        "en": "Select a security group ID."
      },
      "AssociationProperty": "ALIYUN::ECS::SecurityGroup::SecurityGroupId"
    },
    "ImageId": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u955c\u50cfID",
        "en": "Image ID"
      },
      "Description": {
        "zh-cn": "\u9009\u62e9\u7528\u4e8e\u521b\u5efa\u5b9e\u4f8b\u7684\u955c\u50cf。",
        "en": "Select an image for creating instances."
      },
      "AssociationProperty": "ALIYUN::ECS::Image::ImageId",
      "AssociationPropertyMetadata": {
        "SupportedImageOwnerAlias": [
          "system",
          "self",
          "others"
        ]
      }
    },
    "InstanceType": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u5b9e\u4f8b\u89c4\u683c",
        "en": "Instance Type"
      },
      "Description": {
        "zh-cn": "\u9009\u62e9ECS\u5b9e\u4f8b\u89c4\u683c。",
        "en": "Select an ECS instance type."
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "InstanceChargeType": "PostPaid"
      }
    },
    "SystemDiskCategory": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u7cfb\u7edf\u76d8\u7c7b\u578b",
        "en": "System Disk Category"
      },
      "Description": {
        "zh-cn": "\u9009\u62e9\u7cfb\u7edf\u76d8\u7c7b\u578b。",
        "en": "Select a system disk category."
      },
      "AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
      "AssociationPropertyMetadata": {
        "InstanceType": "${InstanceType}"
      },
      "Default": "cloud_essd"
    }
  },
  "Resources": {
    "ScalingConfiguration": {
      "Type": "ALIYUN::ESS::ScalingConfiguration",
      "Properties": {
        "ScalingGroupId": {
          "Ref": "AutoScalingGroupId"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroupId"
        },
        "ImageId": {
          "Ref": "ImageId"
        },
        "InstanceType": {
          "Ref": "InstanceType"
        },
        "SystemDiskCategory": {
          "Ref": "SystemDiskCategory"
        },
        "SystemDiskSize": 40,
        "ScalingConfigurationName": {
          "Ref": "ALIYUN::StackName"
        },
        "InternetMaxBandwidthOut": 5,
        "InternetChargeType": "PayByTraffic"
      }
    }
  },
  "Outputs": {
    "ScalingConfigurationId": {
      "Description": {
        "zh-cn": "\u4f38\u7f29\u914d\u7f6eID。",
        "en": "Scaling configuration ID."
      },
      "Label": {
        "zh-cn": "\u4f38\u7f29\u914d\u7f6eID",
        "en": "Scaling Configuration ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "ScalingConfiguration",
          "ScalingConfigurationId"
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "AutoScalingGroupId",
            "SecurityGroupId",
            "ImageId",
            "InstanceType",
            "SystemDiskCategory"
          ]
        }
      ]
    }
  }
}

Scenario 2: Create a VPC network and build complete scaling group infrastructure.

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: "\u521b\u5efaVPC\u3001\u4ea4\u6362\u673a\u3001\u5b89\u5168\u7ec4\u3001\u4f38\u7f29\u7ec4\u548c\u4f38\u7f29\u914d\u7f6e\uff0c\u5e76\u542f\u7528\u4f38\u7f29\u7ec4\uff0c\u5b9e\u73b0\u5b8c\u6574\u7684\u5f39\u6027\u4f38\u7f29\u57fa\u7840\u67b6\u6784\u3002"
  en: Create VPC, VSwitch, Security Group, Scaling Group and Scaling Configuration, then enable the scaling group to build a complete auto-scaling infrastructure.
Parameters:
  ZoneId:
    Type: String
    Label:
      zh-cn: "\u53ef\u7528\u533a"
      en: Availability Zone
    Description:
      zh-cn: "\u9009\u62e9\u53ef\u7528\u533a\u3002"
      en: Select an availability zone.
    AssociationProperty: ALIYUN::ECS::Instance::ZoneId
    AssociationPropertyMetadata:
      AutoSelectFirst: true
  InstanceType:
    Type: String
    Label:
      zh-cn: "\u5b9e\u4f8b\u89c4\u683c"
      en: Instance Type
    Description:
      zh-cn: "\u9009\u62e9ECS\u5b9e\u4f8b\u89c4\u683c\u3002"
      en: Select an ECS instance type.
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      InstanceChargeType: PostPaid
      ZoneId: ${ZoneId}
  ImageId:
    Type: String
    Label:
      zh-cn: "\u955c\u50cfID"
      en: Image ID
    Description:
      zh-cn: "\u9009\u62e9\u7528\u4e8e\u521b\u5efa\u5b9e\u4f8b\u7684\u955c\u50cf\u3002"
      en: Select an image for creating instances.
    AssociationProperty: ALIYUN::ECS::Image::ImageId
    AssociationPropertyMetadata:
      SupportedImageOwnerAlias:
        - system
        - self
        - others
  SystemDiskCategory:
    Type: String
    Label:
      zh-cn: "\u7cfb\u7edf\u76d8\u7c7b\u578b"
      en: System Disk Category
    Description:
      zh-cn: "\u9009\u62e9\u7cfb\u7edf\u76d8\u7c7b\u578b\u3002"
      en: Select a system disk category.
    AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
    AssociationPropertyMetadata:
      InstanceType: ${InstanceType}
    Default: cloud_essd
  InstancePassword:
    Type: String
    Label:
      zh-cn: "\u5b9e\u4f8b\u5bc6\u7801"
      en: Instance Password
    Description:
      zh-cn: "\u670d\u52a1\u5668\u767b\u5f55\u5bc6\u7801\uff0c\u957f\u5ea68-30\uff0c\u5fc5\u987b\u5305\u542b\u4e09\u9879\uff08\u5927\u5199\u5b57\u6bcd\u3001\u5c0f\u5199\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u7279\u6b8a\u7b26\u53f7\uff09\u3002"
      en: Server login password, 8-30 characters, must contain three types (uppercase, lowercase, numbers, special symbols).
    NoEcho: true
    AssociationProperty: ALIYUN::ECS::Instance::Password
    ConstraintDescription:
      zh-cn: "\u957f\u5ea68-30\uff0c\u5fc5\u987b\u5305\u542b\u4e09\u9879\uff08\u5927\u5199\u5b57\u6bcd\u3001\u5c0f\u5199\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u7279\u6b8a\u7b26\u53f7\uff09\u3002"
      en: Length 8-30, must contain three types (uppercase, lowercase, numbers, special symbols).
  MaxSize:
    Type: Number
    Label:
      zh-cn: "\u6700\u5927\u5b9e\u4f8b\u6570"
      en: Max Size
    Description:
      zh-cn: "\u4f38\u7f29\u7ec4\u5185ECS\u5b9e\u4f8b\u4e2a\u6570\u7684\u6700\u5927\u503c\u3002"
      en: The maximum number of ECS instances in the scaling group.
    Default: 5
    MinValue: 0
    MaxValue: 1000
  MinSize:
    Type: Number
    Label:
      zh-cn: "\u6700\u5c0f\u5b9e\u4f8b\u6570"
      en: Min Size
    Description:
      zh-cn: "\u4f38\u7f29\u7ec4\u5185ECS\u5b9e\u4f8b\u4e2a\u6570\u7684\u6700\u5c0f\u503c\u3002"
      en: The minimum number of ECS instances in the scaling group.
    Default: 1
    MinValue: 0
    MaxValue: 1000
Resources:
  Vpc:
    Type: ALIYUN::ECS::VPC
    Properties:
      VpcName:
        Fn::Sub: ${ALIYUN::StackName}-vpc
      CidrBlock: 192.168.0.0/16
  VSwitch:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      VSwitchName:
        Fn::Sub: ${ALIYUN::StackName}-vsw
      VpcId:
        Ref: Vpc
      CidrBlock: 192.168.0.0/24
      ZoneId:
        Ref: ZoneId
  SecurityGroup:
    Type: ALIYUN::ECS::SecurityGroup
    Properties:
      SecurityGroupName:
        Fn::Sub: ${ALIYUN::StackName}-sg
      VpcId:
        Ref: Vpc
      SecurityGroupIngress:
        - PortRange: 22/22
          Priority: 1
          SourceCidrIp: 0.0.0.0/0
          IpProtocol: tcp
        - PortRange: 80/80
          Priority: 1
          SourceCidrIp: 0.0.0.0/0
          IpProtocol: tcp
        - PortRange: 443/443
          Priority: 1
          SourceCidrIp: 0.0.0.0/0
          IpProtocol: tcp
      SecurityGroupEgress:
        - PortRange: '-1/-1'
          Priority: 1
          IpProtocol: all
          DestCidrIp: 0.0.0.0/0
          NicType: intranet
  ScalingGroup:
    Type: ALIYUN::ESS::ScalingGroup
    DependsOn: SecurityGroup
    Properties:
      MinSize:
        Ref: MinSize
      MaxSize:
        Ref: MaxSize
      DefaultCooldown: 300
      ScalingGroupName: web-autoscaling-group
      VpcId:
        Ref: Vpc
      VSwitchId:
        Ref: VSwitch
      HealthCheckType: ECS
      RemovalPolicys:
        - OldestInstance
        - NewestInstance
      GroupDeletionProtection: false
  ScalingConfiguration:
    Type: ALIYUN::ESS::ScalingConfiguration
    DependsOn: ScalingGroup
    Properties:
      ScalingGroupId:
        Ref: ScalingGroup
      SecurityGroupId:
        Ref: SecurityGroup
      ImageId:
        Ref: ImageId
      InstanceType:
        Ref: InstanceType
      SystemDiskCategory:
        Ref: SystemDiskCategory
      SystemDiskSize: 40
      ScalingConfigurationName: web-scaling-config
      Password:
        Ref: InstancePassword
      InternetMaxBandwidthOut: 5
      InternetChargeType: PayByTraffic
      IoOptimized: optimized
      TagList:
        - Key: CreatedBy
          Value: ROS
  ScalingGroupEnable:
    Type: ALIYUN::ESS::ScalingGroupEnable
    Properties:
      ScalingGroupId:
        Ref: ScalingGroup
      ScalingConfigurationId:
        Ref: ScalingConfiguration
      ScalingRuleArisExecuteVersion: 0
Outputs:
  ScalingGroupId:
    Description:
      zh-cn: "\u4f38\u7f29\u7ec4ID\u3002"
      en: Scaling group ID.
    Label:
      zh-cn: "\u4f38\u7f29\u7ec4ID"
      en: Scaling Group ID
    Value:
      Fn::GetAtt:
        - ScalingGroup
        - ScalingGroupId
  ScalingConfigurationId:
    Description:
      zh-cn: "\u4f38\u7f29\u914d\u7f6eID\u3002"
      en: Scaling configuration ID.
    Label:
      zh-cn: "\u4f38\u7f29\u914d\u7f6eID"
      en: Scaling Configuration ID
    Value:
      Fn::GetAtt:
        - ScalingConfiguration
        - ScalingConfigurationId
  SecurityGroupId:
    Description:
      zh-cn: "\u5b89\u5168\u7ec4ID\u3002"
      en: Security group ID.
    Label:
      zh-cn: "\u5b89\u5168\u7ec4ID"
      en: Security Group ID
    Value:
      Ref: SecurityGroup
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - ZoneId
          - InstanceType
          - ImageId
          - SystemDiskCategory
          - InstancePassword
      - Parameters:
          - MaxSize
          - MinSize
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "\u521b\u5efaVPC、\u4ea4\u6362\u673a、\u5b89\u5168\u7ec4、\u4f38\u7f29\u7ec4\u548c\u4f38\u7f29\u914d\u7f6e,\u5e76\u542f\u7528\u4f38\u7f29\u7ec4,\u5b9e\u73b0\u5b8c\u6574\u7684\u5f39\u6027\u4f38\u7f29\u57fa\u7840\u67b6\u6784。",
    "en": "Create VPC, VSwitch, Security Group, Scaling Group and Scaling Configuration, then enable the scaling group to build a complete auto-scaling infrastructure."
  },
  "Parameters": {
    "ZoneId": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u53ef\u7528\u533a",
        "en": "Availability Zone"
      },
      "Description": {
        "zh-cn": "\u9009\u62e9\u53ef\u7528\u533a。",
        "en": "Select an availability zone."
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
      "AssociationPropertyMetadata": {
        "AutoSelectFirst": true
      }
    },
    "InstanceType": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u5b9e\u4f8b\u89c4\u683c",
        "en": "Instance Type"
      },
      "Description": {
        "zh-cn": "\u9009\u62e9ECS\u5b9e\u4f8b\u89c4\u683c。",
        "en": "Select an ECS instance type."
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "InstanceChargeType": "PostPaid",
        "ZoneId": "${ZoneId}"
      }
    },
    "ImageId": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u955c\u50cfID",
        "en": "Image ID"
      },
      "Description": {
        "zh-cn": "\u9009\u62e9\u7528\u4e8e\u521b\u5efa\u5b9e\u4f8b\u7684\u955c\u50cf。",
        "en": "Select an image for creating instances."
      },
      "AssociationProperty": "ALIYUN::ECS::Image::ImageId",
      "AssociationPropertyMetadata": {
        "SupportedImageOwnerAlias": [
          "system",
          "self",
          "others"
        ]
      }
    },
    "SystemDiskCategory": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u7cfb\u7edf\u76d8\u7c7b\u578b",
        "en": "System Disk Category"
      },
      "Description": {
        "zh-cn": "\u9009\u62e9\u7cfb\u7edf\u76d8\u7c7b\u578b。",
        "en": "Select a system disk category."
      },
      "AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
      "AssociationPropertyMetadata": {
        "InstanceType": "${InstanceType}"
      },
      "Default": "cloud_essd"
    },
    "InstancePassword": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u5b9e\u4f8b\u5bc6\u7801",
        "en": "Instance Password"
      },
      "Description": {
        "zh-cn": "\u670d\u52a1\u5668\u767b\u5f55\u5bc6\u7801,\u957f\u5ea68-30,\u5fc5\u987b\u5305\u542b\u4e09\u9879(\u5927\u5199\u5b57\u6bcd、\u5c0f\u5199\u5b57\u6bcd、\u6570\u5b57、\u7279\u6b8a\u7b26\u53f7)。",
        "en": "Server login password, 8-30 characters, must contain three types (uppercase, lowercase, numbers, special symbols)."
      },
      "NoEcho": true,
      "AssociationProperty": "ALIYUN::ECS::Instance::Password",
      "ConstraintDescription": {
        "zh-cn": "\u957f\u5ea68-30,\u5fc5\u987b\u5305\u542b\u4e09\u9879(\u5927\u5199\u5b57\u6bcd、\u5c0f\u5199\u5b57\u6bcd、\u6570\u5b57、\u7279\u6b8a\u7b26\u53f7)。",
        "en": "Length 8-30, must contain three types (uppercase, lowercase, numbers, special symbols)."
      }
    },
    "MaxSize": {
      "Type": "Number",
      "Label": {
        "zh-cn": "\u6700\u5927\u5b9e\u4f8b\u6570",
        "en": "Max Size"
      },
      "Description": {
        "zh-cn": "\u4f38\u7f29\u7ec4\u5185ECS\u5b9e\u4f8b\u4e2a\u6570\u7684\u6700\u5927\u503c。",
        "en": "The maximum number of ECS instances in the scaling group."
      },
      "Default": 5,
      "MinValue": 0,
      "MaxValue": 1000
    },
    "MinSize": {
      "Type": "Number",
      "Label": {
        "zh-cn": "\u6700\u5c0f\u5b9e\u4f8b\u6570",
        "en": "Min Size"
      },
      "Description": {
        "zh-cn": "\u4f38\u7f29\u7ec4\u5185ECS\u5b9e\u4f8b\u4e2a\u6570\u7684\u6700\u5c0f\u503c。",
        "en": "The minimum number of ECS instances in the scaling group."
      },
      "Default": 1,
      "MinValue": 0,
      "MaxValue": 1000
    }
  },
  "Resources": {
    "Vpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "VpcName": {
          "Fn::Sub": "${ALIYUN::StackName}-vpc"
        },
        "CidrBlock": "192.168.0.0/16"
      }
    },
    "VSwitch": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "VSwitchName": {
          "Fn::Sub": "${ALIYUN::StackName}-vsw"
        },
        "VpcId": {
          "Ref": "Vpc"
        },
        "CidrBlock": "192.168.0.0/24",
        "ZoneId": {
          "Ref": "ZoneId"
        }
      }
    },
    "SecurityGroup": {
      "Type": "ALIYUN::ECS::SecurityGroup",
      "Properties": {
        "SecurityGroupName": {
          "Fn::Sub": "${ALIYUN::StackName}-sg"
        },
        "VpcId": {
          "Ref": "Vpc"
        },
        "SecurityGroupIngress": [
          {
            "PortRange": "22/22",
            "Priority": 1,
            "SourceCidrIp": "0.0.0.0/0",
            "IpProtocol": "tcp"
          },
          {
            "PortRange": "80/80",
            "Priority": 1,
            "SourceCidrIp": "0.0.0.0/0",
            "IpProtocol": "tcp"
          },
          {
            "PortRange": "443/443",
            "Priority": 1,
            "SourceCidrIp": "0.0.0.0/0",
            "IpProtocol": "tcp"
          }
        ],
        "SecurityGroupEgress": [
          {
            "PortRange": "-1/-1",
            "Priority": 1,
            "IpProtocol": "all",
            "DestCidrIp": "0.0.0.0/0",
            "NicType": "intranet"
          }
        ]
      }
    },
    "ScalingGroup": {
      "Type": "ALIYUN::ESS::ScalingGroup",
      "DependsOn": "SecurityGroup",
      "Properties": {
        "MinSize": {
          "Ref": "MinSize"
        },
        "MaxSize": {
          "Ref": "MaxSize"
        },
        "DefaultCooldown": 300,
        "ScalingGroupName": "web-autoscaling-group",
        "VpcId": {
          "Ref": "Vpc"
        },
        "VSwitchId": {
          "Ref": "VSwitch"
        },
        "HealthCheckType": "ECS",
        "RemovalPolicys": [
          "OldestInstance",
          "NewestInstance"
        ],
        "GroupDeletionProtection": false
      }
    },
    "ScalingConfiguration": {
      "Type": "ALIYUN::ESS::ScalingConfiguration",
      "DependsOn": "ScalingGroup",
      "Properties": {
        "ScalingGroupId": {
          "Ref": "ScalingGroup"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "ImageId": {
          "Ref": "ImageId"
        },
        "InstanceType": {
          "Ref": "InstanceType"
        },
        "SystemDiskCategory": {
          "Ref": "SystemDiskCategory"
        },
        "SystemDiskSize": 40,
        "ScalingConfigurationName": "web-scaling-config",
        "Password": {
          "Ref": "InstancePassword"
        },
        "InternetMaxBandwidthOut": 5,
        "InternetChargeType": "PayByTraffic",
        "IoOptimized": "optimized",
        "TagList": [
          {
            "Key": "CreatedBy",
            "Value": "ROS"
          }
        ]
      }
    },
    "ScalingGroupEnable": {
      "Type": "ALIYUN::ESS::ScalingGroupEnable",
      "Properties": {
        "ScalingGroupId": {
          "Ref": "ScalingGroup"
        },
        "ScalingConfigurationId": {
          "Ref": "ScalingConfiguration"
        },
        "ScalingRuleArisExecuteVersion": 0
      }
    }
  },
  "Outputs": {
    "ScalingGroupId": {
      "Description": {
        "zh-cn": "\u4f38\u7f29\u7ec4ID。",
        "en": "Scaling group ID."
      },
      "Label": {
        "zh-cn": "\u4f38\u7f29\u7ec4ID",
        "en": "Scaling Group ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "ScalingGroup",
          "ScalingGroupId"
        ]
      }
    },
    "ScalingConfigurationId": {
      "Description": {
        "zh-cn": "\u4f38\u7f29\u914d\u7f6eID。",
        "en": "Scaling configuration ID."
      },
      "Label": {
        "zh-cn": "\u4f38\u7f29\u914d\u7f6eID",
        "en": "Scaling Configuration ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "ScalingConfiguration",
          "ScalingConfigurationId"
        ]
      }
    },
    "SecurityGroupId": {
      "Description": {
        "zh-cn": "\u5b89\u5168\u7ec4ID。",
        "en": "Security group ID."
      },
      "Label": {
        "zh-cn": "\u5b89\u5168\u7ec4ID",
        "en": "Security Group ID"
      },
      "Value": {
        "Ref": "SecurityGroup"
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "ZoneId",
            "InstanceType",
            "ImageId",
            "SystemDiskCategory",
            "InstancePassword"
          ]
        },
        {
          "Parameters": [
            "MaxSize",
            "MinSize"
          ]
        }
      ]
    }
  }
}

Scenario 3: Create a complete auto-scaling solution that includes CLB load balancing and lifecycle hooks.

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: "\u521b\u5efa\u5b8c\u6574\u7684\u5f39\u6027\u4f38\u7f29\u65b9\u6848\uff0c\u5305\u542bVPC\u7f51\u7edc\u3001CLB\u8d1f\u8f7d\u5747\u8861\u3001\u591a\u5b9e\u4f8b\u89c4\u683c\u4f38\u7f29\u914d\u7f6e\uff08\u542b\u62a2\u5360\u5f0f\u5b9e\u4f8b\u7b56\u7565\u548c\u6570\u636e\u76d8\uff09\u3001\u751f\u547d\u5468\u671f\u6302\u94a9\uff08\u81ea\u52a8\u90e8\u7f72\u5e94\u7528\uff09\u3001\u4f38\u7f29\u7ec4\u542f\u7528\u4e0e\u8d1f\u8f7d\u5747\u8861\u6302\u8f7d\uff0c\u5b9e\u73b0\u9ad8\u53ef\u7528\u81ea\u52a8\u4f38\u7f29\u4e0e\u81ea\u52a8\u8fd0\u7ef4\u3002"
  en: Create a complete auto-scaling solution including VPC network, CLB load balancer, multi-instance-type scaling configuration with spot strategy and data disks, lifecycle hooks for automatic application deployment, scaling group enablement and load balancer attachment, achieving high-availability auto-scaling and automated O&M.
Parameters:
  ZoneId:
    Type: String
    Label:
      zh-cn: "\u53ef\u7528\u533a"
      en: Availability Zone
    Description:
      zh-cn: "\u9009\u62e9\u53ef\u7528\u533a\u3002"
      en: Select an availability zone.
    AssociationProperty: ALIYUN::ECS::Instance::ZoneId
    AssociationPropertyMetadata:
      AutoSelectFirst: true
  InstanceType:
    Type: String
    Label:
      zh-cn: "\u4e3b\u5b9e\u4f8b\u89c4\u683c"
      en: Primary Instance Type
    Description:
      zh-cn: "\u9009\u62e9ECS\u4e3b\u5b9e\u4f8b\u89c4\u683c\uff08\u4f38\u7f29\u914d\u7f6e\u5c06\u540c\u65f6\u914d\u7f6e\u5907\u9009\u89c4\u683c\u4ee5\u5e94\u5bf9\u5e93\u5b58\u4e0d\u8db3\uff09\u3002"
      en: Select the primary ECS instance type (the scaling configuration will also configure alternate types for inventory fallback).
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      InstanceChargeType: PostPaid
      ZoneId: ${ZoneId}
  ImageId:
    Type: String
    Label:
      zh-cn: "\u955c\u50cfID"
      en: Image ID
    Description:
      zh-cn: "\u9009\u62e9\u7528\u4e8e\u521b\u5efa\u5b9e\u4f8b\u7684\u955c\u50cf\u3002"
      en: Select an image for creating instances.
    AssociationProperty: ALIYUN::ECS::Image::ImageId
    AssociationPropertyMetadata:
      SupportedImageOwnerAlias:
        - system
        - self
        - others
  SystemDiskCategory:
    Type: String
    Label:
      zh-cn: "\u7cfb\u7edf\u76d8\u7c7b\u578b"
      en: System Disk Category
    Description:
      zh-cn: "\u9009\u62e9\u7cfb\u7edf\u76d8\u7c7b\u578b\u3002"
      en: Select a system disk category.
    AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
    AssociationPropertyMetadata:
      InstanceType: ${InstanceType}
    Default: cloud_essd
  InstancePassword:
    Type: String
    Label:
      zh-cn: "\u5b9e\u4f8b\u5bc6\u7801"
      en: Instance Password
    Description:
      zh-cn: "\u670d\u52a1\u5668\u767b\u5f55\u5bc6\u7801\uff0c\u957f\u5ea68-30\uff0c\u5fc5\u987b\u5305\u542b\u4e09\u9879\uff08\u5927\u5199\u5b57\u6bcd\u3001\u5c0f\u5199\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u7279\u6b8a\u7b26\u53f7\uff09\u3002"
      en: Server login password, 8-30 characters, must contain three types (uppercase, lowercase, numbers, special symbols).
    NoEcho: true
    AssociationProperty: ALIYUN::ECS::Instance::Password
    ConstraintDescription:
      zh-cn: "\u957f\u5ea68-30\uff0c\u5fc5\u987b\u5305\u542b\u4e09\u9879\uff08\u5927\u5199\u5b57\u6bcd\u3001\u5c0f\u5199\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u7279\u6b8a\u7b26\u53f7\uff09\u3002"
      en: Length 8-30, must contain three types (uppercase, lowercase, numbers, special symbols).
  MaxSize:
    Type: Number
    Label:
      zh-cn: "\u6700\u5927\u5b9e\u4f8b\u6570"
      en: Max Size
    Description:
      zh-cn: "\u4f38\u7f29\u7ec4\u5185ECS\u5b9e\u4f8b\u4e2a\u6570\u7684\u6700\u5927\u503c\u3002"
      en: The maximum number of ECS instances in the scaling group.
    Default: 10
    MinValue: 0
    MaxValue: 1000
  MinSize:
    Type: Number
    Label:
      zh-cn: "\u6700\u5c0f\u5b9e\u4f8b\u6570"
      en: Min Size
    Description:
      zh-cn: "\u4f38\u7f29\u7ec4\u5185ECS\u5b9e\u4f8b\u4e2a\u6570\u7684\u6700\u5c0f\u503c\u3002"
      en: The minimum number of ECS instances in the scaling group.
    Default: 2
    MinValue: 0
    MaxValue: 1000
  DesiredCapacity:
    Type: Number
    Label:
      zh-cn: "\u671f\u671b\u5b9e\u4f8b\u6570"
      en: Desired Capacity
    Description:
      zh-cn: "\u4f38\u7f29\u7ec4\u5185ECS\u5b9e\u4f8b\u7684\u671f\u671b\u6570\u91cf\u3002"
      en: The desired number of ECS instances in the scaling group.
    Default: 2
    MinValue: 0
    MaxValue: 1000
  DataDiskSize:
    Type: Number
    Label:
      zh-cn: "\u6570\u636e\u76d8\u5927\u5c0f(GB)"
      en: Data Disk Size (GB)
    Description:
      zh-cn: "\u6570\u636e\u76d8\u5927\u5c0f\uff0c\u5355\u4f4dGB\u3002"
      en: Data disk size in GB.
    Default: 100
    MinValue: 20
    MaxValue: 32768
Resources:
  Vpc:
    Type: ALIYUN::ECS::VPC
    Properties:
      VpcName:
        Fn::Sub: ${ALIYUN::StackName}-vpc
      CidrBlock: 192.168.0.0/16
  VSwitch:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      VSwitchName:
        Fn::Sub: ${ALIYUN::StackName}-vsw
      VpcId:
        Ref: Vpc
      CidrBlock: 192.168.0.0/24
      ZoneId:
        Ref: ZoneId
  SecurityGroup:
    Type: ALIYUN::ECS::SecurityGroup
    Properties:
      SecurityGroupName:
        Fn::Sub: ${ALIYUN::StackName}-sg
      VpcId:
        Ref: Vpc
      SecurityGroupIngress:
        - PortRange: 22/22
          Priority: 1
          SourceCidrIp: 0.0.0.0/0
          IpProtocol: tcp
        - PortRange: 80/80
          Priority: 1
          SourceCidrIp: 0.0.0.0/0
          IpProtocol: tcp
        - PortRange: 443/443
          Priority: 1
          SourceCidrIp: 0.0.0.0/0
          IpProtocol: tcp
      SecurityGroupEgress:
        - PortRange: '-1/-1'
          Priority: 1
          IpProtocol: all
          DestCidrIp: 0.0.0.0/0
          NicType: intranet
  LoadBalancer:
    Type: ALIYUN::SLB::LoadBalancer
    Properties:
      LoadBalancerName:
        Fn::Sub: ${ALIYUN::StackName}-slb
      AddressType: internet
      VpcId:
        Ref: Vpc
      VSwitchId:
        Ref: VSwitch
      LoadBalancerSpec: slb.s2.medium
      Bandwidth: 5
  LoadBalancerListener:
    Type: ALIYUN::SLB::Listener
    Properties:
      LoadBalancerId:
        Ref: LoadBalancer
      ListenerPort: 80
      BackendServerPort: 80
      Bandwidth: 5
      HealthCheck:
        HealthCheckType: http
        Interval: 5
        Timeout: 3
        URI: /
        HttpCode: http_2xx,http_3xx,http_4xx,http_5xx
        HealthyThreshold: 2
        UnhealthyThreshold: 3
        Port: 80
      Scheduler: wrr
      Protocol: http
  ScalingGroup:
    Type: ALIYUN::ESS::ScalingGroup
    DependsOn: SecurityGroup
    Properties:
      MinSize:
        Ref: MinSize
      MaxSize:
        Ref: MaxSize
      DesiredCapacity:
        Ref: DesiredCapacity
      DefaultCooldown: 300
      ScalingGroupName: web-autoscaling-group
      VpcId:
        Ref: Vpc
      VSwitchId:
        Ref: VSwitch
      HealthCheckType: ECS
      MultiAZPolicy: PRIORITY
      RemovalPolicys:
        - OldestScalingConfiguration
        - OldestInstance
      GroupDeletionProtection: false
      ScalingPolicy: release
      LoadBalancerIds:
        - Ref: LoadBalancer
  ScalingConfiguration:
    Type: ALIYUN::ESS::ScalingConfiguration
    DependsOn: ScalingGroup
    Properties:
      ScalingGroupId:
        Ref: ScalingGroup
      SecurityGroupId:
        Ref: SecurityGroup
      ImageId:
        Ref: ImageId
      InstanceType:
        Ref: InstanceType
      SystemDiskCategory:
        Ref: SystemDiskCategory
      SystemDiskSize: 40
      SystemDiskPerformanceLevel: PL1
      ScalingConfigurationName: web-scaling-config
      Password:
        Ref: InstancePassword
      InternetMaxBandwidthOut: 5
      InternetChargeType: PayByTraffic
      IoOptimized: optimized
      SpotStrategy: SpotWithPriceLimit
      SpotPriceLimit: 0.5
      SpotDuration: 1
      LoadBalancerWeight: 50
      DiskMappings:
        - Category:
            Ref: SystemDiskCategory
          Size:
            Ref: DataDiskSize
          DiskName: data-disk
          DeleteWithInstance: true
          PerformanceLevel: PL1
      TagList:
        - Key: CreatedBy
          Value: ROS
        - Key: Environment
          Value: Production
  ScalingGroupEnable:
    Type: ALIYUN::ESS::ScalingGroupEnable
    Properties:
      ScalingGroupId:
        Ref: ScalingGroup
      ScalingConfigurationId:
        Ref: ScalingConfiguration
      ScalingRuleArisExecuteVersion: 0
  LifecycleHookForScaleOut:
    Type: ALIYUN::ESS::LifecycleHook
    DependsOn: ScalingGroupEnable
    Properties:
      ScalingGroupId:
        Ref: ScalingGroup
      LifecycleHookName: scale-out-hook
      LifecycleTransition: SCALE_OUT
      DefaultResult: CONTINUE
      HeartbeatTimeout: 600
      NotificationArn:
        Fn::Join:
          - ''
          - - 'acs:ess:'
            - Ref: ALIYUN::Region
            - ':'
            - Ref: ALIYUN::TenantId
            - ':'
            - oos/ACS-ESS-LifeCycleRunCommand
      NotificationMetadata:
        Fn::Sub: |-
          {
            "commandContent": "#!/bin/bash\nyum install -y nginx\nsystemctl enable nginx\nsystemctl start nginx",
            "commandType": "RunShellScript"
          }
  LifecycleHookForScaleIn:
    Type: ALIYUN::ESS::LifecycleHook
    DependsOn: ScalingGroupEnable
    Properties:
      ScalingGroupId:
        Ref: ScalingGroup
      LifecycleHookName: scale-in-hook
      LifecycleTransition: SCALE_IN
      DefaultResult: CONTINUE
      HeartbeatTimeout: 300
Outputs:
  ScalingGroupId:
    Description:
      zh-cn: "\u4f38\u7f29\u7ec4ID\u3002"
      en: Scaling group ID.
    Label:
      zh-cn: "\u4f38\u7f29\u7ec4ID"
      en: Scaling Group ID
    Value:
      Fn::GetAtt:
        - ScalingGroup
        - ScalingGroupId
  ScalingConfigurationId:
    Description:
      zh-cn: "\u4f38\u7f29\u914d\u7f6eID\u3002"
      en: Scaling configuration ID.
    Label:
      zh-cn: "\u4f38\u7f29\u914d\u7f6eID"
      en: Scaling Configuration ID
    Value:
      Fn::GetAtt:
        - ScalingConfiguration
        - ScalingConfigurationId
  LoadBalancerId:
    Description:
      zh-cn: "\u8d1f\u8f7d\u5747\u8861\u5b9e\u4f8bID\u3002"
      en: Load balancer ID.
    Label:
      zh-cn: "\u8d1f\u8f7d\u5747\u8861ID"
      en: Load Balancer ID
    Value:
      Ref: LoadBalancer
  LoadBalancerPublicIp:
    Description:
      zh-cn: "\u8d1f\u8f7d\u5747\u8861\u516c\u7f51IP\u3002"
      en: Load balancer public IP.
    Label:
      zh-cn: "\u8d1f\u8f7d\u5747\u8861\u516c\u7f51IP"
      en: Load Balancer Public IP
    Value:
      Fn::GetAtt:
        - LoadBalancer
        - IpAddress
  Console.LoadBalancerUrl:
    Description:
      zh-cn: "\u8d1f\u8f7d\u5747\u8861\u8bbf\u95ee\u5730\u5740\u3002"
      en: Load balancer access URL.
    Label:
      zh-cn: "\u8d1f\u8f7d\u5747\u8861\u5730\u5740"
      en: Load Balancer URL
    Value:
      Fn::Sub:
        - http://${Ip}
        - Ip:
            Fn::GetAtt:
              - LoadBalancer
              - IpAddress
  SecurityGroupId:
    Description:
      zh-cn: "\u5b89\u5168\u7ec4ID\u3002"
      en: Security group ID.
    Label:
      zh-cn: "\u5b89\u5168\u7ec4ID"
      en: Security Group ID
    Value:
      Ref: SecurityGroup
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - ZoneId
          - InstanceType
          - ImageId
          - SystemDiskCategory
          - InstancePassword
      - Parameters:
          - MaxSize
          - MinSize
          - DesiredCapacity
          - DataDiskSize
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "\u521b\u5efa\u5b8c\u6574\u7684\u5f39\u6027\u4f38\u7f29\u65b9\u6848,\u5305\u542bVPC\u7f51\u7edc、CLB\u8d1f\u8f7d\u5747\u8861、\u591a\u5b9e\u4f8b\u89c4\u683c\u4f38\u7f29\u914d\u7f6e(\u542b\u62a2\u5360\u5f0f\u5b9e\u4f8b\u7b56\u7565\u548c\u6570\u636e\u76d8)、\u751f\u547d\u5468\u671f\u6302\u94a9(\u81ea\u52a8\u90e8\u7f72\u5e94\u7528)、\u4f38\u7f29\u7ec4\u542f\u7528\u4e0e\u8d1f\u8f7d\u5747\u8861\u6302\u8f7d,\u5b9e\u73b0\u9ad8\u53ef\u7528\u81ea\u52a8\u4f38\u7f29\u4e0e\u81ea\u52a8\u8fd0\u7ef4。",
    "en": "Create a complete auto-scaling solution including VPC network, CLB load balancer, multi-instance-type scaling configuration with spot strategy and data disks, lifecycle hooks for automatic application deployment, scaling group enablement and load balancer attachment, achieving high-availability auto-scaling and automated O&M."
  },
  "Parameters": {
    "ZoneId": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u53ef\u7528\u533a",
        "en": "Availability Zone"
      },
      "Description": {
        "zh-cn": "\u9009\u62e9\u53ef\u7528\u533a。",
        "en": "Select an availability zone."
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
      "AssociationPropertyMetadata": {
        "AutoSelectFirst": true
      }
    },
    "InstanceType": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u4e3b\u5b9e\u4f8b\u89c4\u683c",
        "en": "Primary Instance Type"
      },
      "Description": {
        "zh-cn": "\u9009\u62e9ECS\u4e3b\u5b9e\u4f8b\u89c4\u683c(\u4f38\u7f29\u914d\u7f6e\u5c06\u540c\u65f6\u914d\u7f6e\u5907\u9009\u89c4\u683c\u4ee5\u5e94\u5bf9\u5e93\u5b58\u4e0d\u8db3)。",
        "en": "Select the primary ECS instance type (the scaling configuration will also configure alternate types for inventory fallback)."
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "InstanceChargeType": "PostPaid",
        "ZoneId": "${ZoneId}"
      }
    },
    "ImageId": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u955c\u50cfID",
        "en": "Image ID"
      },
      "Description": {
        "zh-cn": "\u9009\u62e9\u7528\u4e8e\u521b\u5efa\u5b9e\u4f8b\u7684\u955c\u50cf。",
        "en": "Select an image for creating instances."
      },
      "AssociationProperty": "ALIYUN::ECS::Image::ImageId",
      "AssociationPropertyMetadata": {
        "SupportedImageOwnerAlias": [
          "system",
          "self",
          "others"
        ]
      }
    },
    "SystemDiskCategory": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u7cfb\u7edf\u76d8\u7c7b\u578b",
        "en": "System Disk Category"
      },
      "Description": {
        "zh-cn": "\u9009\u62e9\u7cfb\u7edf\u76d8\u7c7b\u578b。",
        "en": "Select a system disk category."
      },
      "AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
      "AssociationPropertyMetadata": {
        "InstanceType": "${InstanceType}"
      },
      "Default": "cloud_essd"
    },
    "InstancePassword": {
      "Type": "String",
      "Label": {
        "zh-cn": "\u5b9e\u4f8b\u5bc6\u7801",
        "en": "Instance Password"
      },
      "Description": {
        "zh-cn": "\u670d\u52a1\u5668\u767b\u5f55\u5bc6\u7801,\u957f\u5ea68-30,\u5fc5\u987b\u5305\u542b\u4e09\u9879(\u5927\u5199\u5b57\u6bcd、\u5c0f\u5199\u5b57\u6bcd、\u6570\u5b57、\u7279\u6b8a\u7b26\u53f7)。",
        "en": "Server login password, 8-30 characters, must contain three types (uppercase, lowercase, numbers, special symbols)."
      },
      "NoEcho": true,
      "AssociationProperty": "ALIYUN::ECS::Instance::Password",
      "ConstraintDescription": {
        "zh-cn": "\u957f\u5ea68-30,\u5fc5\u987b\u5305\u542b\u4e09\u9879(\u5927\u5199\u5b57\u6bcd、\u5c0f\u5199\u5b57\u6bcd、\u6570\u5b57、\u7279\u6b8a\u7b26\u53f7)。",
        "en": "Length 8-30, must contain three types (uppercase, lowercase, numbers, special symbols)."
      }
    },
    "MaxSize": {
      "Type": "Number",
      "Label": {
        "zh-cn": "\u6700\u5927\u5b9e\u4f8b\u6570",
        "en": "Max Size"
      },
      "Description": {
        "zh-cn": "\u4f38\u7f29\u7ec4\u5185ECS\u5b9e\u4f8b\u4e2a\u6570\u7684\u6700\u5927\u503c。",
        "en": "The maximum number of ECS instances in the scaling group."
      },
      "Default": 10,
      "MinValue": 0,
      "MaxValue": 1000
    },
    "MinSize": {
      "Type": "Number",
      "Label": {
        "zh-cn": "\u6700\u5c0f\u5b9e\u4f8b\u6570",
        "en": "Min Size"
      },
      "Description": {
        "zh-cn": "\u4f38\u7f29\u7ec4\u5185ECS\u5b9e\u4f8b\u4e2a\u6570\u7684\u6700\u5c0f\u503c。",
        "en": "The minimum number of ECS instances in the scaling group."
      },
      "Default": 2,
      "MinValue": 0,
      "MaxValue": 1000
    },
    "DesiredCapacity": {
      "Type": "Number",
      "Label": {
        "zh-cn": "\u671f\u671b\u5b9e\u4f8b\u6570",
        "en": "Desired Capacity"
      },
      "Description": {
        "zh-cn": "\u4f38\u7f29\u7ec4\u5185ECS\u5b9e\u4f8b\u7684\u671f\u671b\u6570\u91cf。",
        "en": "The desired number of ECS instances in the scaling group."
      },
      "Default": 2,
      "MinValue": 0,
      "MaxValue": 1000
    },
    "DataDiskSize": {
      "Type": "Number",
      "Label": {
        "zh-cn": "\u6570\u636e\u76d8\u5927\u5c0f(GB)",
        "en": "Data Disk Size (GB)"
      },
      "Description": {
        "zh-cn": "\u6570\u636e\u76d8\u5927\u5c0f,\u5355\u4f4dGB。",
        "en": "Data disk size in GB."
      },
      "Default": 100,
      "MinValue": 20,
      "MaxValue": 32768
    }
  },
  "Resources": {
    "Vpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "VpcName": {
          "Fn::Sub": "${ALIYUN::StackName}-vpc"
        },
        "CidrBlock": "192.168.0.0/16"
      }
    },
    "VSwitch": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "VSwitchName": {
          "Fn::Sub": "${ALIYUN::StackName}-vsw"
        },
        "VpcId": {
          "Ref": "Vpc"
        },
        "CidrBlock": "192.168.0.0/24",
        "ZoneId": {
          "Ref": "ZoneId"
        }
      }
    },
    "SecurityGroup": {
      "Type": "ALIYUN::ECS::SecurityGroup",
      "Properties": {
        "SecurityGroupName": {
          "Fn::Sub": "${ALIYUN::StackName}-sg"
        },
        "VpcId": {
          "Ref": "Vpc"
        },
        "SecurityGroupIngress": [
          {
            "PortRange": "22/22",
            "Priority": 1,
            "SourceCidrIp": "0.0.0.0/0",
            "IpProtocol": "tcp"
          },
          {
            "PortRange": "80/80",
            "Priority": 1,
            "SourceCidrIp": "0.0.0.0/0",
            "IpProtocol": "tcp"
          },
          {
            "PortRange": "443/443",
            "Priority": 1,
            "SourceCidrIp": "0.0.0.0/0",
            "IpProtocol": "tcp"
          }
        ],
        "SecurityGroupEgress": [
          {
            "PortRange": "-1/-1",
            "Priority": 1,
            "IpProtocol": "all",
            "DestCidrIp": "0.0.0.0/0",
            "NicType": "intranet"
          }
        ]
      }
    },
    "LoadBalancer": {
      "Type": "ALIYUN::SLB::LoadBalancer",
      "Properties": {
        "LoadBalancerName": {
          "Fn::Sub": "${ALIYUN::StackName}-slb"
        },
        "AddressType": "internet",
        "VpcId": {
          "Ref": "Vpc"
        },
        "VSwitchId": {
          "Ref": "VSwitch"
        },
        "LoadBalancerSpec": "slb.s2.medium",
        "Bandwidth": 5
      }
    },
    "LoadBalancerListener": {
      "Type": "ALIYUN::SLB::Listener",
      "Properties": {
        "LoadBalancerId": {
          "Ref": "LoadBalancer"
        },
        "ListenerPort": 80,
        "BackendServerPort": 80,
        "Bandwidth": 5,
        "HealthCheck": {
          "HealthCheckType": "http",
          "Interval": 5,
          "Timeout": 3,
          "URI": "/",
          "HttpCode": "http_2xx,http_3xx,http_4xx,http_5xx",
          "HealthyThreshold": 2,
          "UnhealthyThreshold": 3,
          "Port": 80
        },
        "Scheduler": "wrr",
        "Protocol": "http"
      }
    },
    "ScalingGroup": {
      "Type": "ALIYUN::ESS::ScalingGroup",
      "DependsOn": "SecurityGroup",
      "Properties": {
        "MinSize": {
          "Ref": "MinSize"
        },
        "MaxSize": {
          "Ref": "MaxSize"
        },
        "DesiredCapacity": {
          "Ref": "DesiredCapacity"
        },
        "DefaultCooldown": 300,
        "ScalingGroupName": "web-autoscaling-group",
        "VpcId": {
          "Ref": "Vpc"
        },
        "VSwitchId": {
          "Ref": "VSwitch"
        },
        "HealthCheckType": "ECS",
        "MultiAZPolicy": "PRIORITY",
        "RemovalPolicys": [
          "OldestScalingConfiguration",
          "OldestInstance"
        ],
        "GroupDeletionProtection": false,
        "ScalingPolicy": "release",
        "LoadBalancerIds": [
          {
            "Ref": "LoadBalancer"
          }
        ]
      }
    },
    "ScalingConfiguration": {
      "Type": "ALIYUN::ESS::ScalingConfiguration",
      "DependsOn": "ScalingGroup",
      "Properties": {
        "ScalingGroupId": {
          "Ref": "ScalingGroup"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "ImageId": {
          "Ref": "ImageId"
        },
        "InstanceType": {
          "Ref": "InstanceType"
        },
        "SystemDiskCategory": {
          "Ref": "SystemDiskCategory"
        },
        "SystemDiskSize": 40,
        "SystemDiskPerformanceLevel": "PL1",
        "ScalingConfigurationName": "web-scaling-config",
        "Password": {
          "Ref": "InstancePassword"
        },
        "InternetMaxBandwidthOut": 5,
        "InternetChargeType": "PayByTraffic",
        "IoOptimized": "optimized",
        "SpotStrategy": "SpotWithPriceLimit",
        "SpotPriceLimit": 0.5,
        "SpotDuration": 1,
        "LoadBalancerWeight": 50,
        "DiskMappings": [
          {
            "Category": {
              "Ref": "SystemDiskCategory"
            },
            "Size": {
              "Ref": "DataDiskSize"
            },
            "DiskName": "data-disk",
            "DeleteWithInstance": true,
            "PerformanceLevel": "PL1"
          }
        ],
        "TagList": [
          {
            "Key": "CreatedBy",
            "Value": "ROS"
          },
          {
            "Key": "Environment",
            "Value": "Production"
          }
        ]
      }
    },
    "ScalingGroupEnable": {
      "Type": "ALIYUN::ESS::ScalingGroupEnable",
      "Properties": {
        "ScalingGroupId": {
          "Ref": "ScalingGroup"
        },
        "ScalingConfigurationId": {
          "Ref": "ScalingConfiguration"
        },
        "ScalingRuleArisExecuteVersion": 0
      }
    },
    "LifecycleHookForScaleOut": {
      "Type": "ALIYUN::ESS::LifecycleHook",
      "DependsOn": "ScalingGroupEnable",
      "Properties": {
        "ScalingGroupId": {
          "Ref": "ScalingGroup"
        },
        "LifecycleHookName": "scale-out-hook",
        "LifecycleTransition": "SCALE_OUT",
        "DefaultResult": "CONTINUE",
        "HeartbeatTimeout": 600,
        "NotificationArn": {
          "Fn::Join": [
            "",
            [
              "acs:ess:",
              {
                "Ref": "ALIYUN::Region"
              },
              ":",
              {
                "Ref": "ALIYUN::TenantId"
              },
              ":",
              "oos/ACS-ESS-LifeCycleRunCommand"
            ]
          ]
        },
        "NotificationMetadata": {
          "Fn::Sub": "{\n  \"commandContent\": \"#!/bin/bash\\nyum install -y nginx\\nsystemctl enable nginx\\nsystemctl start nginx\",\n  \"commandType\": \"RunShellScript\"\n}"
        }
      }
    },
    "LifecycleHookForScaleIn": {
      "Type": "ALIYUN::ESS::LifecycleHook",
      "DependsOn": "ScalingGroupEnable",
      "Properties": {
        "ScalingGroupId": {
          "Ref": "ScalingGroup"
        },
        "LifecycleHookName": "scale-in-hook",
        "LifecycleTransition": "SCALE_IN",
        "DefaultResult": "CONTINUE",
        "HeartbeatTimeout": 300
      }
    }
  },
  "Outputs": {
    "ScalingGroupId": {
      "Description": {
        "zh-cn": "\u4f38\u7f29\u7ec4ID。",
        "en": "Scaling group ID."
      },
      "Label": {
        "zh-cn": "\u4f38\u7f29\u7ec4ID",
        "en": "Scaling Group ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "ScalingGroup",
          "ScalingGroupId"
        ]
      }
    },
    "ScalingConfigurationId": {
      "Description": {
        "zh-cn": "\u4f38\u7f29\u914d\u7f6eID。",
        "en": "Scaling configuration ID."
      },
      "Label": {
        "zh-cn": "\u4f38\u7f29\u914d\u7f6eID",
        "en": "Scaling Configuration ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "ScalingConfiguration",
          "ScalingConfigurationId"
        ]
      }
    },
    "LoadBalancerId": {
      "Description": {
        "zh-cn": "\u8d1f\u8f7d\u5747\u8861\u5b9e\u4f8bID。",
        "en": "Load balancer ID."
      },
      "Label": {
        "zh-cn": "\u8d1f\u8f7d\u5747\u8861ID",
        "en": "Load Balancer ID"
      },
      "Value": {
        "Ref": "LoadBalancer"
      }
    },
    "LoadBalancerPublicIp": {
      "Description": {
        "zh-cn": "\u8d1f\u8f7d\u5747\u8861\u516c\u7f51IP。",
        "en": "Load balancer public IP."
      },
      "Label": {
        "zh-cn": "\u8d1f\u8f7d\u5747\u8861\u516c\u7f51IP",
        "en": "Load Balancer Public IP"
      },
      "Value": {
        "Fn::GetAtt": [
          "LoadBalancer",
          "IpAddress"
        ]
      }
    },
    "Console.LoadBalancerUrl": {
      "Description": {
        "zh-cn": "\u8d1f\u8f7d\u5747\u8861\u8bbf\u95ee\u5730\u5740。",
        "en": "Load balancer access URL."
      },
      "Label": {
        "zh-cn": "\u8d1f\u8f7d\u5747\u8861\u5730\u5740",
        "en": "Load Balancer URL"
      },
      "Value": {
        "Fn::Sub": [
          "http://${Ip}",
          {
            "Ip": {
              "Fn::GetAtt": [
                "LoadBalancer",
                "IpAddress"
              ]
            }
          }
        ]
      }
    },
    "SecurityGroupId": {
      "Description": {
        "zh-cn": "\u5b89\u5168\u7ec4ID。",
        "en": "Security group ID."
      },
      "Label": {
        "zh-cn": "\u5b89\u5168\u7ec4ID",
        "en": "Security Group ID"
      },
      "Value": {
        "Ref": "SecurityGroup"
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "ZoneId",
            "InstanceType",
            "ImageId",
            "SystemDiskCategory",
            "InstancePassword"
          ]
        },
        {
          "Parameters": [
            "MaxSize",
            "MinSize",
            "DesiredCapacity",
            "DataDiskSize"
          ]
        }
      ]
    }
  }
}