All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::ECS::AutoProvisioningGroup

Last Updated:May 30, 2025

ALIYUN::ECS::AutoProvisioningGroup is used to create an auto provisioning group.

Syntax

{
  "Type": "ALIYUN::ECS::AutoProvisioningGroup",
  "Properties": {
    "SpotInstancePoolsToUseCount": Integer,
    "AutoProvisioningGroupName": String,
    "ValidUntil": String,
    "Description": String,
    "PayAsYouGoAllocationStrategy": String,
    "MaxSpotPrice": Number,
    "LaunchTemplateId": String,
    "DefaultTargetCapacityType": String,
    "SpotInstanceInterruptionBehavior": String,
    "SpotTargetCapacity": String,
    "SpotAllocationStrategy": String,
    "PayAsYouGoTargetCapacity": String,
    "TotalTargetCapacity": String,
    "AutoProvisioningGroupType": String,
    "LaunchTemplateVersion": String,
    "ValidFrom": String,
    "ExcessCapacityTerminationPolicy": String,
    "TerminateInstances": Boolean,
    "TerminateInstancesWithExpiration": Boolean,
    "CheckExecutionStatus": Boolean,
    "LaunchConfiguration": Map
    "LaunchTemplateConfig": List,
    "MinTargetCapacity": String,
    "ResourcePoolOptions": Map,
    "DataDiskConfig": List,
    "ResourceGroupId": String,
    "SystemDiskConfig": List
  }
}

Properties

Property

Type

Required

Editable

Description

Constraint

SpotInstancePoolsToUseCount

Integer

No

No

The number of instances that the auto provisioning group creates by selecting the instance type of the lowest price.

The value of this property must be smaller than the number of extended configurations of the launch template.

This property takes effect when SpotAllocationStrategy is set to lowest-price.

AutoProvisioningGroupName

String

No

No

The name of the auto provisioning group.

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

ValidUntil

String

No

No

The expiration time of the auto provisioning group. The auto provisioning group is valid during the time range specified by ValidFrom and ValidUntil.

Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

Description

String

No

No

The description of the auto provisioning group.

None.

PayAsYouGoAllocationStrategy

String

No

No

The policy based on which the auto provisioning group creates pay-as-you-go instances.

Valid values:

  • lowest-price (default): cost optimization policy. The auto provisioning group creates instances by selecting the instance type of the lowest price.

  • prioritized: priority-based policy. The auto provisioning group creates pay-as-you-go instances based on the priority specified in LaunchTemplateConfig.

MaxSpotPrice

Number

No

Yes

The maximum price of preemptible instances in the auto provisioning group.

When the MaxSpotPrice and MaxPrice properties are specified, the smaller value between the property values takes precedence. For more information about MaxPrice, see LaunchTemplateConfig properties.

LaunchTemplateId

String

No

No

The ID of the launch template that you want to associate with the auto provisioning group.

You can call the DescribeLaunchTemplates operation to query available launch templates.

When LaunchTemplateId and LaunchConfiguration are specified, LaunchTemplateId takes precedence.

DefaultTargetCapacityType

String

No

Yes

The type of supplemental instances. When the sum of the PayAsYouGoTargetCapacity and SpotTargetCapacity values is smaller than the TotalTargetCapacity value, the auto provisioning group creates instances of the specified billing method to meet the target capacity.

Valid values:

  • PayAsYouGo: pay-as-you-go instance.

  • Spot (default): preemptible instance.

SpotInstanceInterruptionBehavior

String

No

No

The action to be performed after the excess preemptible instances are stopped.

Valid values:

  • stop (default): retains the excess preemptible instances in the stopped state.

  • terminate: releases the excess preemptible instances in the stopped state.

SpotTargetCapacity

String

No

Yes

The target capacity of preemptible instances in the auto provisioning group.

The value of this property must be smaller than the TotalTargetCapacity value.

SpotAllocationStrategy

String

No

No

The policy for creating preemptible instances.

Valid values:

  • lowest-price (default): cost optimization policy. The auto provisioning group creates instances by selecting the instance type of the lowest price.

  • diversified: balanced distribution policy. The auto provisioning group creates instances in zones that are specified in the extended configurations of the launch template and then evenly distributes the instances across the zones.

PayAsYouGoTargetCapacity

String

No

Yes

The target capacity of pay-as-you-go instances in the auto provisioning group.

The value of this property must be smaller than the TotalTargetCapacity value.

TotalTargetCapacity

String

Yes

Yes

The total target capacity of the auto provisioning group.

The value must be a positive integer that is greater than or equal to the sum of the PayAsYouGoTargetCapacity and SpotTargetCapacity values.

AutoProvisioningGroupType

String

No

No

The delivery type of the auto provisioning group.

Valid values:

  • request: one-time delivery. When the auto provisioning group is started, it delivers instances only once. If the instances fail to be delivered, the auto provisioning group does not retry the delivery.

  • maintain (default): continuous delivery. When the auto provisioning group is started, it attempts to deliver instances that meet the target capacity, and monitors the real-time capacity. Whenever the target capacity of the auto provisioning group is not reached, the auto provisioning group continues to create instances until the target capacity is reached.

LaunchTemplateVersion

String

No

No

The version of the launch template that you want to associate with the auto provisioning group.

You can call the DescribeLaunchTemplateVersions operation to query available instance launch template versions.

ValidFrom

String

No

No

The start time of the auto provisioning group. The auto provisioning group is valid during the time range specified by ValidFrom and ValidUntil.

Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

ExcessCapacityTerminationPolicy

String

No

Yes

Specifies whether to stop excess preemptible instances when the total target capacity of the auto provisioning group is exceeded.

Valid values:

  • no-termination (default): does not stop excess preemptible instances.

  • termination: stops excess preemptible instances. The action to be performed on the stopped instances is specified by SpotInstanceInterruptionBehavior.

TerminateInstances

Boolean

No

No

Specifies whether to release the instances in the auto provisioning group when the auto provisioning group is deleted.

Valid values:

  • true

  • false (default)

TerminateInstancesWithExpiration

Boolean

No

Yes

Specifies whether to stop preemptible instances when the auto provisioning group expires.

Valid values:

  • true: stops preemptible instances. The action to be performed on the stopped instances is specified by SpotInstanceInterruptionBehavior.

  • false (default): does not stop preemptible instances.

CheckExecutionStatus

Boolean

No

No

Specifies whether to check the execution status.

Valid values:

  • true

  • false

LaunchConfiguration

Map

No

No

The information about the launch configurations.

When LaunchTemplateId and LaunchConfiguration are specified, LaunchTemplateId takes precedence.

For more information, see LaunchConfiguration properties.

LaunchTemplateConfig

List

No

No

The extended configurations of the launch template.

You can specify up to 20 extended configurations.

For more information, see LaunchTemplateConfig properties.

MinTargetCapacity

String

No

No

The minimum target capacity of the auto provisioning group.

The value must be a positive integer.

When you specify this property, take note of the following items:

  • This property takes effect only when AutoProvisioningGroupType is set to instant.

  • If the number of instances that can be created in the current region is smaller than the property value, ALIYUN::ECS::AutoProvisioningGroup fails to be used, and no instances are created.

  • If the number of instances that can be created in the current region is greater than the property value, instances can be created based on the specified properties.

ResourcePoolOptions

Map

No

No

The resource pool options that you want to use to create instances.

For more information, see the "ResourcePoolOptions properties" section of this topic.

DataDiskConfig

List

No

No

The information about data disks of instances.

For more information, see the "DataDiskConfig property" section of this topic.

ResourceGroupId

String

No

Yes

The ID of the resource group to which the auto provisioning group belongs.

None.

SystemDiskConfig

List

No

No

The information about system disks of instances.

For more information, see the "SystemDiskConfig property" section of this topic.

LaunchTemplateConfig syntax

"LaunchTemplateConfig": [
  {
    "Priority": Integer,
    "WeightedCapacity": Integer,
    "VSwitchId": String,
    "InstanceType": String,
    "MaxPrice": Integer,
    "Cores": List,
    "Memories": List,
    "Architectures": List,
    "ExcludedInstanceTypes": List,
    "ImageId": String,
    "BurstablePerformance": String,
    "InstanceFamilyLevel": String
  }
]

LaunchTemplateConfig properties

Property

Type

Required

Editable

Description

Constraint

Priority

Integer

No

No

The priority of the instance type in the extended configuration.

The value must be an integer that is greater than or equal to 0.

A value of 0 specifies the highest priority.

WeightedCapacity

Integer

No

No

The weight of the instance type in the extended configuration.

The value must be an integer that is greater than 0.

A larger value indicates that more computing power is provided by a single instance and fewer instances are required.

The weight is calculated based on the computing power of the specified instance type and the minimum computing power of a single instance in the cluster to be created by the auto provisioning group.

For example, if the minimum computing power of a single instance is 8 vCPUs and 60 GiB of memory, you can set the weight of the instance type that has 8 vCPUs and 60 GiB of memory to 1 and the weight of the instance type that has 16 vCPUs and 120 GiB of memory to 2.

VSwitchId

String

Yes

No

The ID of the vSwitch in the extended configuration.

The Elastic Compute Service (ECS) instances created by using the launch template are connected to the vSwitch, and the zone of the instances is determined by the vSwitch.

InstanceType

String

No

No

The instance type in the extended configuration.

None.

Cores

List

No

No

The number of vCPUs of the instance type in the extended configuration.

None.

Memories

List

No

No

The memory sizes of the instance types.

Unit: GiB. You can use this property to filter the instance types that meet your requirements. For more information, see Overview of instance families. You can specify 1 to 10 memory sizes, indicated by N.

Architectures

List

No

No

The architectures of the instance types.

Valid values:

  • X86: x86.

  • Heterogeneous: heterogeneous computing, such as GPU-accelerated or FPGA-accelerated.

  • BareMetal: ECS Bare Metal Instance.

  • Arm: Arm.

  • SuperComputeCluster: Super Computing Cluster (SCC).

By default, all values are included.

ExcludedInstanceTypes

List

No

No

The instance types that you want to exclude.

You can use the wildcard character (*) to exclude an instance type or an instance family. Examples:

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

  • ecs.c6.*: excludes the c6 instance family.

ImageId

String

No

No

The ID of the image.

None.

BurstablePerformance

String

No

No

Specifies whether to include burstable instance types.

Valid values:

  • Exclude: excludes burstable instance types.

  • Include: includes burstable instance types.

  • Required: includes only burstable instance types.

Default value: Include.

InstanceFamilyLevel

String

No

No

The level of the instance family.

You can use this property to filter the instance types that meet your requirements. Valid values:

  • EntryLevel: entry level (shared instance types). Instance types of this level are the most cost-effective but may not ensure stable computing performance. Instance types of this level are suitable for scenarios in which the CPU utilization is low. For more information, see Shared instance families.

  • EnterpriseLevel: enterprise level. Instance types of this level provide stable performance and dedicated resources and are suitable for business scenarios that require high stability. For more information, see Overview of instance families.

  • CreditEntryLevel: credit-based entry level (burstable instance types). CPU credits are used to ensure computing performance. Instance types of this level are suitable for scenarios in which the CPU utilization is low but may fluctuate in specific cases. For more information, see Overview.

MaxPrice

Integer

No

No

The maximum price of preemptible instances in the extended configuration.

None.

LaunchConfiguration syntax

"LaunchConfiguration": {
  "InstanceDescription": String,
  "SystemDiskName": String,
  "RamRoleName": String,
  "SystemDiskCategory": String,
  "SecurityGroupId": String,
  "CreditSpecification": String,
  "HostName": String,
  "SystemDiskDescription": String,
  "SystemDiskPerformanceLevel": String,
  "DataDisk": List,
  "ImageFamily": String,
  "HostNames": List,
  "InternetMaxBandwidthOut": Integer,
  "SystemDiskBurstingEnabled": Boolean,
  "IoOptimized": String,
  "Tag": List,
  "ImageId": String,
  "ResourceGroupId": String,
  "SystemDiskKMSKeyId": String,
  "KeyPairName": String,
  "PasswordInherit": Boolean,
  "UserData": String,
  "AutoReleaseTime": String,
  "InstanceName": String,
  "SystemDiskSize": Integer,
  "SecurityGroupIds": List,
  "DeploymentSetId": String,
  "InternetChargeType": String,
  "SecurityEnhancementStrategy": String
}

LaunchConfiguration properties

Property

Type

Required

Editable

Description

Constraint

InstanceDescription

String

No

No

The description of the instance.

The description must be 2 to 256 characters in length, and cannot start with http:// or https://.

SystemDiskName

String

No

No

The name of the system disk.

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

RamRoleName

String

No

No

The name of the instance Resource Access Management (RAM) role.

None.

SystemDiskCategory

String

No

No

The category of the system disk.

Valid values:

  • cloud_efficiency: ultra disk.

  • cloud_ssd: standard SSD.

  • cloud_essd: Enterprise SSD (ESSD).

  • cloud: basic disk.

For non-I/O optimized instances of a retired instance type, the default value is cloud. For instances of other types, the default value is cloud_efficiency.

HostNames

List

No

No

The hostnames.

None.

SecurityGroupId

String

Yes

No

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

None.

CreditSpecification

String

No

No

The performance mode of the burstable instance.

Valid values:

  • Standard

  • Unlimited

HostName

String

No

No

The hostname of the instance.

The hostname cannot start or end with a period (.) or hyphen (-). It cannot contain consecutive periods (.) or hyphens (-). The hostname must meet the following requirements:

  • For instances that run Windows, the hostname must be 2 to 15 characters in length, and can contain letters, digits, and hyphens (-). It cannot contain periods (.) or only digits.

  • For instances that run a different operating system, such as Linux, the hostname must be 2 to 64 characters in length. You can use periods (.) to separate the hostname into multiple segments. Each segment can contain letters, digits, and hyphens (-).

SystemDiskBurstingEnabled

Boolean

No

No

Specifies whether to enable the performance burst feature for the system disk.

Valid values:

  • true

  • false

SystemDiskDescription

String

No

No

The description of the system disk.

The description must be 2 to 256 characters in length, and cannot start with http:// or https://.

ImageFamily

String

No

No

The name of the image family.

The name must be 2 to 128 characters in length. It must start with a letter and cannot start with aliyun or acs:. It cannot contain http:// or https://. It can contain letters, digits, colons (:), underscores (_), and hyphens (-).

SecurityGroupIds

List

No

No

The IDs of one or more security groups to which the ECS instance belongs.

None.

AutoReleaseTime

String

No

No

The point in time at which the system automatically releases the ECS instance.

Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The point in time must be within three years from the point in time at which the ECS instance is created.

SystemDiskPerformanceLevel

String

No

No

The performance level (PL) of the ESSD that you want to use as the system disk.

Valid values:

  • PL0 (default): An ESSD can deliver up to 10,000 random read/write IOPS.

  • PL1: An ESSD can deliver up to 50,000 random read/write IOPS.

  • PL2: An ESSD can deliver up to 100,000 random read/write IOPS.

  • PL3: An ESSD can deliver up to 1,000,000 random read/write IOPS.

DataDisk

List

No

No

The data disks.

You can attach up to 16 data disks.

For more information, see DataDisk properties.

InternetMaxBandwidthOut

Integer

No

No

The maximum outbound public bandwidth.

Valid values: 0 to 100.

Default value: 0.

Unit: Mbit/s.

IoOptimized

String

No

No

Specifies whether the instance is I/O optimized.

Valid values:

  • none: The instance is not I/O optimized.

  • optimized: The instance is I/O optimized.

SystemDiskKMSKeyId

String

No

No

The ID of the Key Management Service (KMS) key that you want to use for the system disk.

None.

Tag

List

No

No

The tags of the instance.

You can add up to 20 tags.

For more information, see Tag properties.

ImageId

String

Yes

No

The ID of the image.

None.

ResourceGroupId

String

No

No

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

None.

KeyPairName

String

No

No

The name of the key pair.

Windows instance: You do not need to specify this property. This property is empty by default.

Linux instance: If you specify this property, password-based logons are disabled for Linux instances during initialization.

PasswordInherit

Boolean

No

No

Specifies whether to use the preset password of the image.

Valid values:

  • true

  • false

UserData

String

No

No

The user data of the instance.

The user data must be encoded in Base64. The raw data can be up to 16 KB in size.

InstanceName

String

No

No

The name of the instance.

The default value of this property is the value of InstanceId.

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

SystemDiskSize

Integer

No

No

The size of the system disk.

Valid values: 20 to 500. The size of the system disk must be greater than or equal to the size of the image.

Default value: 40 or the image size.

Unit: GiB.

InternetChargeType

String

No

No

The metering method for network usage.

Valid values:

  • PayByBandwidth: pay-by-bandwidth.

  • PayByTraffic: pay-by-data-transfer.

Note

When the pay-by-data-transfer metering method is used, the maximum inbound and outbound bandwidths are used as upper limits of bandwidths instead of guaranteed performance specifications. When demands outstrip resource supplies, the maximum bandwidths may be limited. If you require guaranteed bandwidths for your business, use the pay-by-bandwidth metering method.

SystemDiskProvisionedIops

Integer

No

No

The provisioned IOPS of the system disk.

None.

SystemDiskEncrypted

Boolean

No

No

Specifies whether to encrypt the system disk.

Valid values:

  • true

  • false

DeploymentSetId

String

No

No

The ID of the deployment set.

None.

SecurityEnhancementStrategy

String

No

No

Specifies whether to enable security hardening.

Valid values:

  • Active: enables security hardening. This value is valid only for public images.

  • Deactive: disables security hardening. This value is valid only for all types of images.

DataDisk syntax

"DataDisk": [
  {
    "DiskName": String,
    "Size": Integer,
    "Category": String,
    "Description": String,
    "DeleteWithInstance": Boolean,
    "SnapshotId": String,
    "Device": String,
    "Encrypted": Boolean,
    "KmsKeyId": String,
    "InternetChargeType": String,
    "ProvisionedIops": Integer,
    "BurstingEnabled": Boolean
    "PerformanceLevel": String
  }
]

DataDisk properties

Property

Type

Required

Editable

Description

Constraint

DiskName

String

No

No

The name of the data disk.

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

Size

Integer

No

No

The size of the data disk.

Valid values:

  • Valid values when Category is set to cloud_efficiency: 20 to 32768.

  • Valid values when Category is set to cloud_ssd: 20 to 32768.

  • Valid values when Category is set to cloud_essd: 20 to 32768.

  • Valid values when Category is set to cloud: 5 to 2000.

Unit: GiB.

Device

String

No

No

The device name of the data disk that you want to attach to the ECS instance.

Examples: /dev/xvda to /dev/xvdz.

Category

String

No

No

The category of data disk.

Valid values:

  • cloud_efficiency: ultra disk.

  • cloud_ssd: standard SSD.

  • cloud_essd: ESSD.

  • cloud: basic disk.

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

ProvisionedIops

Integer

No

No

The provisioned IOPS.

None.

BurstingEnabled

Boolean

No

No

Specifies whether to enable the burst mode.

Valid values:

  • true

  • false (default)

Description

String

No

No

The description of the data disk.

The description must be 2 to 256 characters in length, and cannot start with http:// or https://.

DeleteWithInstance

Boolean

No

No

Specifies whether to release the data disk when the instance to which the data disk is attached is released.

Valid values:

  • true (default)

  • false

SnapshotId

String

No

No

The ID of the snapshot that you want to use to create the data disk.

If you specify this property, the Size value is ignored. The actual size of the data disk is the size of the snapshot that is specified by SnapshotId.

Note

Use snapshots that were created after July 15, 2013. Otherwise, an error is returned, and your request is rejected.

Encrypted

Boolean

No

No

Specifies whether to encrypt the data disk.

Valid values:

  • true

  • false (default)

KmsKeyId

String

No

No

The ID of the key that you want to use for the data disk.

None.

InternetChargeType

String

No

No

The metering method for network usage.

Valid values:

  • PayByBandwidth: pay-by-bandwidth.

  • PayByTraffic: pay-by-data-transfer.

Note

When the pay-by-data-transfer metering method is used, the maximum inbound and outbound bandwidths are used as upper limits of bandwidths instead of guaranteed performance specifications. When demands outstrip resource supplies, the maximum bandwidths may be limited. If you require guaranteed bandwidths for your business, use the pay-by-bandwidth metering method.

PerformanceLevel

String

No

No

The PL of the ESSD that you want to use as the data disk.

Valid values:

  • PL0 (default): An ESSD can deliver up to 10,000 random read/write IOPS.

  • PL1: An ESSD can deliver up to 50,000 random read/write IOPS.

  • PL2: An ESSD can deliver up to 100,000 random read/write IOPS.

  • PL3: An ESSD can deliver up to 1,000,000 random read/write IOPS.

Tag syntax

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

Tag properties

Property

Type

Required

Editable

Description

Constraint

Key

String

Yes

No

The key of the tag.

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

Value

String

No

No

The value of the tag.

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

DataDiskConfig syntax

"DataDiskConfig": [
  {
    "DiskCategory": String
  }
]  

DataDiskConfig property

Property

Type

Required

Editable

Description

Constraint

DiskCategory

String

Yes

No

The information about the data disk of the instance.

None.

SystemDiskConfig syntax

"SystemDiskConfig": [
  {
    "DiskCategory": String
  }
]  

SystemDiskConfig property

Property

Type

Required

Editable

Description

Constraint

DiskCategory

String

Yes

No

The information about the system disk of the instance.

None.

ResourcePoolOptions syntax

"ResourcePoolOptions":
  {
    "Strategy": String,
    "PrivatePoolIds": List
  }

ResourcePoolOptions properties

Property

Type

Required

Editable

Description

Constraint

Strategy

String

No

No

The strategy for selecting resource pools that are used to create instances. Resource pools include the private pools that are generated after elasticity assurances or capacity reservations take effect and the public pool.

Valid values:

  • PrivatePoolFirst: uses private pools first. If you use this value and specify ResourcePoolOptions.PrivatePoolIds, the specified private pools are used first. If you do not specify private pools or the specified private pools have insufficient capacity, matching open private pools are used. If no matching open private pools exist, the public pool is used.

  • PrivatePoolOnly: uses only private pools. If you use this value, you must specify ResourcePoolOptions.PrivatePoolIds. If the specified private pools have insufficient capacity, instances fail to be created.

  • PublicPoolOnly: uses the public pool.

Default value: PublicPoolOnly.

PrivatePoolIds

List

No

No

The IDs of the private pools.

The ID of a private pool is the same as the ID of the elasticity assurance or capacity reservation that is associated with the private pool. You can specify the IDs only of private pools in Target mode for this property. You can configure up to 20 private pools.

Return values

Fn::GetAtt

  • AutoProvisioningGroupId: the ID of the auto provisioning group.

  • AutoProvisioningGroupName: the name of the auto provisioning group.

Examples

ROSTemplateFormatVersion: '2015-09-01'
Description: Test ECS AutoProvisioningGroup
Parameters:
  LaunchTemplateId:
    Type: String
    Description: |-
      The ID of the instance launch template associated with the auto provisioning group.
      You can call the DescribeLaunchTemplates operation to query available instance launch templates.
      An auto provisioning group can be associated with only one instance launch template.
      But you can configure multiple extended configurations for the launch template through
      the LaunchTemplateConfig parameter.
  PayAsYouGoTargetCapacity:
    Type: String
    Description: The target capacity of pay-as-you-go instances in the auto provisioning group.
    Default: '1'
  TotalTargetCapacity:
    Type: String
    Description: |-
      The total target capacity of the auto provisioning group. The target capacity consists
      of the following three parts:
      The target capacity of pay-as-you-go instances specified by the PayAsYouGoTargetCapacity parameter
      The target capacity of preemptible instances specified by the SpotTargetCapacity parameter
      The supplemental capacity besides PayAsYouGoTargetCapacity and SpotTargetCapacity
    Default: '2'
  SpotTargetCapacity:
    Type: String
    Description: The target capacity of preemptible instances in the auto provisioning group.
    Default: '1'
  AutoProvisioningGroupName:
    Type: String
    Description: |-
      The name of the auto provisioning group to be created. It must be 2 to 128 characters
      in length. It must start with a letter but cannot start with http:// or https://.
      It can contain letters, digits, colons (:), underscores (_), and hyphens (-).
    Default: mytest
  SpotAllocationStrategy:
    Type: String
    Description: |-
      The scale-out policy for preemptible instances. Valid values:
      lowest-price: The cost optimization policy the auto provisioning group follows to select instance
      types of the lowest cost to create instances.
      diversified: The distribution balancing policy the auto provisioning group follows to evenly create
      instances across zones specified in multiple extended template configurations.
      Default value: lowest-price
    AllowedValues:
      - diversified
      - lowest-price
    Default: lowest-price
  PayAsYouGoAllocationStrategy:
    Type: String
    Description: |-
      The scale-out policy for pay-as-you-go instances. Valid values:
      lowest-price: The cost optimization policy the auto provisioning group follows to select instance
      types of the lowest cost to create instances.
      prioritized: The priority-based policy the auto provisioning group follows to create instances.
      The priority of an instance type is specified by the LaunchTemplateConfig.N.Priority parameter.
      Default value: lowest-price
    AllowedValues:
      - lowest-price
      - prioritized
    Default: lowest-price
  MaxSpotPrice:
    Type: Number
    Description: |-
      The global maximum price for preemptible instances in the auto provisioning group.
      If both the MaxSpotPrice and LaunchTemplateConfig.N.MaxPrice parameters are specified, the maximum price is the lower value of the two.
    Default: 5
  DefaultTargetCapacityType:
    Type: String
    Description: |-
      The type of supplemental instances. When the total value of PayAsYouGoTargetCapacity and SpotTargetCapacity is smaller than the value of TotalTargetCapacity, the auto provisioning group will create instances of the specified type to meet
      the capacity requirements. Valid values:
      PayAsYouGo: Pay-as-you-go instances.
      Spot: Preemptible instances.
      Default value: Spot
    AllowedValues:
      - PayAsYouGo
      - Spot
    Default: PayAsYouGo
  AutoProvisioningGroupType:
    Type: String
    Description: |-
      The type of the auto provisioning group. Valid values:
      request: One-time delivery. After the auto provisioning group is started, it only attempts
      to create an instance cluster once. If the cluster fails to be created, the group
      does not try again.
      maintain: The continuous delivery and maintain capacity type. After the auto provisioning group
      is started, it continuously attempts to create and maintain the instance cluster.
      The auto provisioning group compares the real-time and target capacity of the cluster.
      If the cluster does not meet the target capacity, the group will create instances
      until the cluster meets the target capacity.
      Default value: maintain
    AllowedValues:
      - maintain
      - request
    Default: maintain
  ExcessCapacityTerminationPolicy:
    Type: String
    Description: |-
      The shutdown policy for excess preemptible instances followed when the capacity of
      the auto provisioning group exceeds the target capacity. Valid values:
      no-termination: Excess preemptible instances are not shut down.
      termination: Excess preemptible instances are to be shut down. The action to be performed on these
      shutdown instances is specified by the SpotInstanceInterruptionBehavior parameter.
      Default value: no-termination
    AllowedValues:
      - no-termination
      - termination
    Default: termination
  TerminateInstances:
    Type: Boolean
    Description: |-
      Specifies whether to release instances of the auto provisioning group. Valid values:
      true
      false
      Default: false
    AllowedValues:
      - true
      - false
    Default: true
  TerminateInstancesWithExpiration:
    Type: Boolean
    Description: |-
      The shutdown policy for preemptible instances when the auto provisioning group expires.
      Valid values:
      true: shuts down preemptible instances. The action to be performed on these shutdown instances
      is specified by the SpotInstanceInterruptionBehavior parameter.
      false: does not shut down preemptible instances.
      Default: false
    AllowedValues:
      - true
      - false
    Default: true
Resources:
  AutoProvisioningGroup:
    Type: ALIYUN::ECS::AutoProvisioningGroup
    Properties:
      LaunchTemplateId:
        Ref: LaunchTemplateId
      LaunchTemplateVersion: '1'
      TotalTargetCapacity:
        Ref: TotalTargetCapacity
      PayAsYouGoTargetCapacity:
        Ref: PayAsYouGoTargetCapacity
      SpotTargetCapacity:
        Ref: SpotTargetCapacity
      AutoProvisioningGroupName:
        Ref: AutoProvisioningGroupName
      SpotAllocationStrategy:
        Ref: SpotAllocationStrategy
      Description: Test AutoProvisioningGroup
      PayAsYouGoAllocationStrategy:
        Ref: PayAsYouGoAllocationStrategy
      MaxSpotPrice:
        Ref: MaxSpotPrice
      DefaultTargetCapacityType:
        Ref: DefaultTargetCapacityType
      AutoProvisioningGroupType:
        Ref: AutoProvisioningGroupType
      ExcessCapacityTerminationPolicy:
        Ref: ExcessCapacityTerminationPolicy
      TerminateInstances:
        Ref: TerminateInstances
      TerminateInstancesWithExpiration:
        Ref: TerminateInstancesWithExpiration
Outputs:
  AutoProvisioningGroupId:
    Description: The ID of the auto provisioning group.
    Value:
      Fn::GetAtt:
        - AutoProvisioningGroup
        - AutoProvisioningGroupId
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": "Test ECS AutoProvisioningGroup",
  "Parameters": {
    "LaunchTemplateId": {
      "Type": "String",
      "Description": "The ID of the instance launch template associated with the auto provisioning group.\nYou can call the DescribeLaunchTemplates operation to query available instance launch templates.\nAn auto provisioning group can be associated with only one instance launch template.\nBut you can configure multiple extended configurations for the launch template through\nthe LaunchTemplateConfig parameter."
    },
    "PayAsYouGoTargetCapacity": {
      "Type": "String",
      "Description": "The target capacity of pay-as-you-go instances in the auto provisioning group.",
      "Default": "1"
    },
    "TotalTargetCapacity": {
      "Type": "String",
      "Description": "The total target capacity of the auto provisioning group. The target capacity consists\nof the following three parts:\nThe target capacity of pay-as-you-go instances specified by the PayAsYouGoTargetCapacity parameter\nThe target capacity of preemptible instances specified by the SpotTargetCapacity parameter\nThe supplemental capacity besides PayAsYouGoTargetCapacity and SpotTargetCapacity",
      "Default": "2"
    },
    "SpotTargetCapacity": {
      "Type": "String",
      "Description": "The target capacity of preemptible instances in the auto provisioning group.",
      "Default": "1"
    },
    "AutoProvisioningGroupName": {
      "Type": "String",
      "Description": "The name of the auto provisioning group to be created. It must be 2 to 128 characters\nin length. It must start with a letter but cannot start with http:// or https://.\nIt can contain letters, digits, colons (:), underscores (_), and hyphens (-).",
      "Default": "mytest"
    },
    "SpotAllocationStrategy": {
      "Type": "String",
      "Description": "The scale-out policy for preemptible instances. Valid values:\nlowest-price: The cost optimization policy the auto provisioning group follows to select instance\ntypes of the lowest cost to create instances.\ndiversified: The distribution balancing policy the auto provisioning group follows to evenly create\ninstances across zones specified in multiple extended template configurations.\nDefault value: lowest-price",
      "AllowedValues": [
        "diversified",
        "lowest-price"
      ],
      "Default": "lowest-price"
    },
    "PayAsYouGoAllocationStrategy": {
      "Type": "String",
      "Description": "The scale-out policy for pay-as-you-go instances. Valid values:\nlowest-price: The cost optimization policy the auto provisioning group follows to select instance\ntypes of the lowest cost to create instances.\nprioritized: The priority-based policy the auto provisioning group follows to create instances.\nThe priority of an instance type is specified by the LaunchTemplateConfig.N.Priority parameter.\nDefault value: lowest-price",
      "AllowedValues": [
        "lowest-price",
        "prioritized"
      ],
      "Default": "lowest-price"
    },
    "MaxSpotPrice": {
      "Type": "Number",
      "Description": "The global maximum price for preemptible instances in the auto provisioning group.\nIf both the MaxSpotPrice and LaunchTemplateConfig.N.MaxPrice parameters are specified, the maximum price is the lower value of the two.",
      "Default": 5
    },
    "DefaultTargetCapacityType": {
      "Type": "String",
      "Description": "The type of supplemental instances. When the total value of PayAsYouGoTargetCapacity and SpotTargetCapacity is smaller than the value of TotalTargetCapacity, the auto provisioning group will create instances of the specified type to meet\nthe capacity requirements. Valid values:\nPayAsYouGo: Pay-as-you-go instances.\nSpot: Preemptible instances.\nDefault value: Spot",
      "AllowedValues": [
        "PayAsYouGo",
        "Spot"
      ],
      "Default": "PayAsYouGo"
    },
    "AutoProvisioningGroupType": {
      "Type": "String",
      "Description": "The type of the auto provisioning group. Valid values:\nrequest: One-time delivery. After the auto provisioning group is started, it only attempts\nto create an instance cluster once. If the cluster fails to be created, the group\ndoes not try again.\nmaintain: The continuous delivery and maintain capacity type. After the auto provisioning group\nis started, it continuously attempts to create and maintain the instance cluster.\nThe auto provisioning group compares the real-time and target capacity of the cluster.\nIf the cluster does not meet the target capacity, the group will create instances\nuntil the cluster meets the target capacity.\nDefault value: maintain",
      "AllowedValues": [
        "maintain",
        "request"
      ],
      "Default": "maintain"
    },
    "ExcessCapacityTerminationPolicy": {
      "Type": "String",
      "Description": "The shutdown policy for excess preemptible instances followed when the capacity of\nthe auto provisioning group exceeds the target capacity. Valid values:\nno-termination: Excess preemptible instances are not shut down.\ntermination: Excess preemptible instances are to be shut down. The action to be performed on these\nshutdown instances is specified by the SpotInstanceInterruptionBehavior parameter.\nDefault value: no-termination",
      "AllowedValues": [
        "no-termination",
        "termination"
      ],
      "Default": "termination"
    },
    "TerminateInstances": {
      "Type": "Boolean",
      "Description": "Specifies whether to release instances of the auto provisioning group. Valid values:\ntrue\nfalse\nDefault: false",
      "AllowedValues": [
        true,
        false
      ],
      "Default": true
    },
    "TerminateInstancesWithExpiration": {
      "Type": "Boolean",
      "Description": "The shutdown policy for preemptible instances when the auto provisioning group expires.\nValid values:\ntrue: shuts down preemptible instances. The action to be performed on these shutdown instances\nis specified by the SpotInstanceInterruptionBehavior parameter.\nfalse: does not shut down preemptible instances.\nDefault: false",
      "AllowedValues": [
        true,
        false
      ],
      "Default": true
    }
  },
  "Resources": {
    "AutoProvisioningGroup": {
      "Type": "ALIYUN::ECS::AutoProvisioningGroup",
      "Properties": {
        "LaunchTemplateId": {
          "Ref": "LaunchTemplateId"
        },
        "LaunchTemplateVersion": "1",
        "TotalTargetCapacity": {
          "Ref": "TotalTargetCapacity"
        },
        "PayAsYouGoTargetCapacity": {
          "Ref": "PayAsYouGoTargetCapacity"
        },
        "SpotTargetCapacity": {
          "Ref": "SpotTargetCapacity"
        },
        "AutoProvisioningGroupName": {
          "Ref": "AutoProvisioningGroupName"
        },
        "SpotAllocationStrategy": {
          "Ref": "SpotAllocationStrategy"
        },
        "Description": "Test AutoProvisioningGroup",
        "PayAsYouGoAllocationStrategy": {
          "Ref": "PayAsYouGoAllocationStrategy"
        },
        "MaxSpotPrice": {
          "Ref": "MaxSpotPrice"
        },
        "DefaultTargetCapacityType": {
          "Ref": "DefaultTargetCapacityType"
        },
        "AutoProvisioningGroupType": {
          "Ref": "AutoProvisioningGroupType"
        },
        "ExcessCapacityTerminationPolicy": {
          "Ref": "ExcessCapacityTerminationPolicy"
        },
        "TerminateInstances": {
          "Ref": "TerminateInstances"
        },
        "TerminateInstancesWithExpiration": {
          "Ref": "TerminateInstancesWithExpiration"
        }
      }
    }
  },
  "Outputs": {
    "AutoProvisioningGroupId": {
      "Description": "The ID of the auto provisioning group.",
      "Value": {
        "Fn::GetAtt": [
          "AutoProvisioningGroup",
          "AutoProvisioningGroupId"
        ]
      }
    }
  }
}