全部產品
Search
文件中心

Resource Orchestration Service:ALIYUN::ECS::AutoProvisioningGroup

更新時間:May 30, 2025

ALIYUN::ECS::AutoProvisioningGroup類型用於建立彈性供應組。

文法

{
  "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
  }
}

屬性

屬性名稱

類型

必須

允許更新

描述

約束

SpotInstancePoolsToUseCount

Integer

彈性供應組選擇價格最低的執行個體規格建立執行個體的數量。

取值:小於啟動模板的擴充設定數量。

當SpotAllocationStrategy取值為lowest-price時該參數生效。

AutoProvisioningGroupName

String

彈性供應組的名稱。

長度為2~128個字元,必須以英文字母或漢字開頭,不能以http://https://開頭。可包含英文字母、漢字、數字、半形冒號(:)、底線(_)和短劃線(-)。

ValidUntil

String

彈性供應組的到期時間,和ValidFrom共同確定有效時段。

按照ISO8601標準表示,並使用UTC時間,格式為yyyy-MM-ddTHH:mm:ssZ

Description

String

彈性供應組的描述資訊。

PayAsYouGoAllocationStrategy

String

建立隨用隨付執行個體的策略。

取值:

  • lowest-price(預設值):成本最佳化策略。選擇價格最低的執行個體規格。

  • prioritized:優先順序策略。按照LaunchTemplateConfig設定的優先順序建立執行個體。

MaxSpotPrice

Number

彈性供應組內搶佔式執行個體的最高價格。

同時設定MaxSpotPrice和MaxPrice時,以最低值為準。關於MaxPrice參數的更多資訊,請參見LaunchTemplateConfig屬性

LaunchTemplateId

String

彈性供應組關聯的執行個體啟動模板的ID。

您可以調用DescribeLaunchTemplates查詢可用的執行個體啟動模板。

同時指定LaunchTemplateId和LaunchConfiguration時,優先使用啟動模板。

DefaultTargetCapacityType

String

PayAsYouGoTargetCapacity和SpotTargetCapacity之和小於TotalTargetCapacity時,指定差額容量的計費方式。

取值:

  • PayAsYouGo:隨用隨付執行個體。

  • Spot(預設值):搶佔式執行個體。

SpotInstanceInterruptionBehavior

String

停止了超額搶佔式執行個體後的下一步動作。

取值:

  • stop(預設值):保持停止狀態。

  • terminate:釋放。

SpotTargetCapacity

String

彈性供應組內,搶佔式執行個體的目標容量。

取值:小於TotalTargetCapacity參數取值。

SpotAllocationStrategy

String

建立搶佔式執行個體的策略。

取值:

  • lowest-price(預設值):成本最佳化策略。選擇價格最低的執行個體規格。

  • diversified:均衡可用性區域分布策略。在擴充啟動模板指定的可用性區域內建立執行個體,均勻分布到各可用性區域。

PayAsYouGoTargetCapacity

String

彈性供應組內,隨用隨付執行個體的目標容量。

取值:小於TotalTargetCapacity參數取值。

TotalTargetCapacity

String

彈性供應組的目標總容量。

取值(正整數):總容量必須大於等於PayAsYouGoTargetCapacity(指定的隨用隨付執行個體目標容量)和SpotTargetCapacity(指定的搶佔式執行個體目標容量)取值之和。

AutoProvisioningGroupType

String

彈性供應組的交付類型。

取值:

  • request:一次性。供應組僅在啟動時交付執行個體叢集,調度失敗後不再重試。

  • maintain(預設值):持續供應。供應組在啟動時嘗試交付執行個體叢集,並監控即時容量,未達到目標容量則嘗試繼續建立ECS執行個體。

LaunchTemplateVersion

String

彈性供應組關聯執行個體啟動模板的版本。

您可以調用DescribeLaunchTemplateVersions查詢可用的執行個體啟動模板版本。

ValidFrom

String

彈性供應組的啟動時間,和ValidUntil共同確定有效時段。

按照ISO8601標準表示,並使用UTC時間,格式為yyyy-MM-ddTHH:mm:ssZ

ExcessCapacityTerminationPolicy

String

彈性供應組超過目標總容量時,是否停止超額的搶佔式執行個體。

取值:

  • no-termination(預設值):繼續運行。

  • termination:停止。停止後的下一步動作由SpotInstanceInterruptionBehavior指定。

TerminateInstances

Boolean

刪除彈性供應組時,是否釋放組內執行個體。

取值:

  • true:釋放。

  • false(預設值):不釋放。

TerminateInstancesWithExpiration

Boolean

彈性供應組到期時,是否停止搶佔式執行個體。

取值:

  • true:停止。停止後的下一步動作由SpotInstanceInterruptionBehavior指定。

  • false(預設值):繼續運行。

CheckExecutionStatus

Boolean

是否檢查執行狀態。

取值:

  • true:檢查。

  • false:不檢查。

LaunchConfiguration

Map

啟動配置資訊。

同時指定LaunchTemplateId和LaunchConfiguration時,優先使用啟動模板。

更多資訊,請參見LaunchConfiguration屬性

LaunchTemplateConfig

List

啟動模板的擴充設定。

最多支援20個擴充設定。

更多資訊,請參見LaunchTemplateConfig屬性

MinTargetCapacity

String

彈性供應組的目標最小容量。

取值範圍:正整數。

當您設定該參數後,需要注意:

  • 僅建立一次性同步交付類型的彈性供應組(AutoProvisioningGroupType=instant)時,該參數生效。

  • 如果當前地區下的執行個體庫存小於該參數值,則會導致調用介面失敗,不會建立執行個體。

  • 如果當前地區下的執行個體庫存大於該參數值,則按照已設定的其他參數值正常建立執行個體。

ResourcePoolOptions

Map

建立執行個體時使用的資源集區策略。

更多資訊,請參見ResourcePoolOptions屬性。

DataDiskConfig

List

執行個體資料盤資訊列表。

更多資訊,請參見DataDiskConfig屬性。

ResourceGroupId

String

彈性供應組所在的企業資源組 ID。

SystemDiskConfig

List

執行個體系統硬碟資訊列表。

更多資訊,請參見SystemDiskConfig屬性。

LaunchTemplateConfig文法

"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屬性

屬性名稱

類型

必須

允許更新

描述

約束

Priority

Integer

擴充啟動模板中執行個體規格的優先順序。

取值:大於等於0。

取值為0時優先順序最高。

WeightedCapacity

Integer

擴充啟動模板中,執行個體規格的權重。

取值:大於0的整數。

取值越高,單台執行個體滿足計算力需求的能力越大,所需的執行個體數量越小。

您可以根據指定執行個體規格的計算力和叢集單節點最低計算力得出權重值。

例如:單節點最低計算力為8vCPU、60GiB,則8vCPU、60GiB的執行個體規格權重可以設定為1;16vCPU、120GiB的執行個體規格權重可以設定為2。

VSwitchId

String

擴充啟動模板中,ECS執行個體加入的交換器的ID。

擴充模板中啟動的ECS執行個體可用性區域由交換器決定。

InstanceType

String

擴充啟動模板對應的執行個體規格。

Cores

List

擴充啟動模板中,執行個體規格的vCPU核心數目。

Memories

List

執行個體規格的記憶體大小列表。

執行個體規格的記憶體大小,單位為 GiB,用於篩選符合要求的執行個體規格範圍。更多資訊,請參見執行個體規格類型系列。N 的取值範圍:1~10。

Architectures

List

執行個體規格所屬的架構類型列表。

執行個體規格所屬的架構類型。取值範圍:

  • X86:X86 計算。

  • Heterogeneous:異構計算,例如 GPU 或 FPGA 等。

  • BareMental:ECS Bare Metal Instance。

  • Arm:Arm 計算。

  • SuperComputeCluster:Super Computing Cluster。

預設值:包含所有架構類型。

ExcludedInstanceTypes

List

需要排除的執行個體規格列表。

需要排除的執行個體規格。通過使用萬用字元(*)可以排除單個規格或者整個規格類型系列。例如:

  • ecs.c6.large:表示排除 ecs.c6.large 執行個體規格。

  • ecs.c6.*:表示排除整個 c6 規格類型系列的執行個體規格。

ImageId

String

鏡像 ID

BurstablePerformance

String

是否為效能突發執行個體規格。

取值範圍:

  • Exclude:不包含效能突發執行個體規格。

  • Include:包含效能突發執行個體規格。

  • Required:只包含效能突發執行個體規格。

預設值:Include。

InstanceFamilyLevel

String

執行個體規格類型系列層級。

用於篩選符合要求的執行個體規格範圍。取值範圍:

  • EntryLevel:入門級,即共用型執行個體規格。成本更低,但是無法保證執行個體計算效能的穩定。適用於平時 CPU 使用率低的業務情境。更多資訊,請參見共用型

  • EnterpriseLevel:企業級。效能穩定,資源獨享,適用於對穩定性要求高的業務情境。更多資訊,請參見執行個體規格類型系列

  • CreditEntryLevel:積分入門級,即突發效能執行個體。通過 CPU 積分來保證計算效能,適用於平時 CPU 使用率低、偶有突發 CPU 使用率的情況。更多資訊,請參見突發效能執行個體概述

MaxPrice

Integer

擴充啟動模板中,搶佔式執行個體的價格上限。

LaunchConfiguration文法

"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屬性

屬性名稱

類型

必須

允許更新

描述

約束

InstanceDescription

String

執行個體描述。

長度為2~256個字元,不能以http://https://開頭。

SystemDiskName

String

系統硬碟名稱。

長度為2~128個字元。必須以英文字母或漢字開頭,不能以http://https://開頭。可以包含英文字母、漢字、數字、半形句號(.)、半形冒號(:)、底線(_)和短劃線(-)。

RamRoleName

String

執行個體RAM角色名稱。

SystemDiskCategory

String

系統硬碟類型。

取值:

  • cloud_efficiency:高效雲端硬碟。

  • cloud_ssd:SSD雲端硬碟。

  • cloud_essd:ESSD雲端硬碟。

  • cloud:普通雲端硬碟。

已停售的執行個體規格且非I/O最佳化執行個體預設值為cloud,否則預設值為cloud_efficiency。

HostNames

List

主機名稱列表。

SecurityGroupId

String

執行個體所屬的安全性群組ID。

CreditSpecification

String

修改突發效能執行個體的運行模式。

取值:

  • Standard:標準模式。

  • Unlimited:無效能約束模式。

HostName

String

執行個體主機名稱。

半形句號(.)和短劃線(-)不能作為首尾字元,更不能連續使用。取值要求如下:

  • Windows執行個體:長度為2~15個字元,不支援半形句號(.),不能全是數字。可包含英文字母、數字和短劃線(-)。

  • 其他類型執行個體(Linux等):長度為2~64個字元,支援多個半形句號(.),點之間為一段,每段可包含英文字母、數字和短劃線(-)。

SystemDiskBurstingEnabled

Boolean

系統硬碟是否開啟Burst(效能突發)。

取值:

  • true:開啟。

  • false:未開啟。

SystemDiskDescription

String

系統硬碟的描述。

長度為2~256個字元,不能以http://https://開頭。

ImageFamily

String

鏡像族系名稱。

長度為 2~128 個英文或中文字元。必須以大小寫字母或中文開頭,不能以aliyunacs:開頭,不能包含http://或者https://。可以包含數字、半形冒號(:)、底線(_)或者短劃線(-)。

SecurityGroupIds

List

ECS所屬的一個或多個安全性群組ID。

AutoReleaseTime

String

ECS執行個體自動釋放的時間。

時間格式必須遵守ISO8601規範,例如:yyyy-MM-ddTHH:mm:ssZ。釋放時間不能超過三年。

SystemDiskPerformanceLevel

String

建立ESSD雲端硬碟作為系統硬碟使用時,設定雲端硬碟的效能等級。

取值:

  • PL0(預設值):單盤最高隨機讀寫IOPS 1萬。

  • PL1:單盤最高隨機讀寫IOPS 5萬。

  • PL2:單盤最高隨機讀寫IOPS 10萬。

  • PL3:單盤最高隨機讀寫IOPS 100萬。

DataDisk

List

資料盤。

最多支援16塊資料盤。

更多資訊,請參見DataDisk屬性

InternetMaxBandwidthOut

Integer

公網出頻寬最大值。

取值範圍:0~100。

預設值:0。

單位為Mbps。

IoOptimized

String

是否為I/O最佳化執行個體。

取值:

  • none:不是I/O最佳化執行個體。

  • optimized:是I/O最佳化執行個體。

SystemDiskKMSKeyId

String

系統硬碟使用的KMS密鑰ID。

Tag

List

執行個體的標籤。

最多20個標籤。

更多資訊,請參見Tag屬性

ImageId

String

鏡像ID。

ResourceGroupId

String

執行個體所在的企業資源組ID。

KeyPairName

String

金鑰組名稱。

Windows執行個體,忽略該參數。預設為空白。

Linux執行個體的密碼登入方式會被初始化成禁止。

PasswordInherit

Boolean

是否使用鏡像預設的密碼。

取值:

  • true:使用。

  • false:不使用。

UserData

String

執行個體自訂資料。

需要以Base64方式編碼,未經處理資料最多為16 KB。

InstanceName

String

執行個體名稱。

預設值為執行個體的InstanceId。

長度為2~128個字元,必須以英文字母或漢字開頭,不能以http://https://開頭。可包含英文字母、漢字、數字、半形冒號(:)、底線(_)、半形句號(.)和短劃線(-)。

SystemDiskSize

Integer

系統硬碟大小。

取值範圍:20~500。必須大於等於鏡像大小。

預設值:40或鏡像大小。

單位:GiB。

InternetChargeType

String

網路計費類型。

取值:

  • PayByBandwidth:按固定頻寬計費。

  • PayByTraffic:按使用流量計費。

說明

按使用流量計費模式下的出入頻寬峰值都是頻寬上限,不作為業務承諾指標。當出現資源爭搶時,頻寬峰值可能會受到限制。如果您的業務需要有頻寬的保障,請使用按固定頻寬計費模式。

SystemDiskProvisionedIops

Integer

系統硬碟預配的 IOPS。

SystemDiskEncrypted

Boolean

系統硬碟是否加密。

取值:

  • true:加密。

  • false:不加密。

DeploymentSetId

String

部署集 ID。

SecurityEnhancementStrategy

String

是否開啟安全強化。

取值:

  • Active:啟用安全強化,只對公用鏡像生效。

  • Deactive:不啟用安全強化,對所有鏡像類型生效。

DataDisk文法

"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屬性

屬性名稱

類型

必須

允許更新

描述

約束

DiskName

String

資料盤名稱。

長度為2~128個字元。必須以英文字母或漢字開頭,不能以http://https://開頭。可包含英文字母、漢字、數字、半形句號(.)、半形冒號(:)、底線(_)和短劃線(-)。

Size

Integer

資料盤的容量大小。

取值範圍:

  • cloud_efficiency:20~32,768。

  • cloud_ssd:20~32,768。

  • cloud_essd:20~32,768。

  • cloud:5~2000。

單位:GiB。

Device

String

資料盤在ECS中的名稱。

取值樣本:/dev/xvd[a-z]

Category

String

資料盤類型。

取值:

  • cloud_efficiency:高效雲端硬碟。

  • cloud_ssd:SSD雲端硬碟。

  • cloud_essd:ESSD雲端硬碟。

  • cloud:普通雲端硬碟。

對於I/O最佳化執行個體,預設值為cloud_efficiency。對於非I/O最佳化執行個體,預設值為cloud。

ProvisionedIops

Integer

預配的IOPS。

BurstingEnabled

Boolean

是否啟用突發。

取值:

  • true:啟用。

  • false(預設值):禁用。

Description

String

資料盤的描述。

長度為2~256個字元,不能以http://https://開頭。

DeleteWithInstance

Boolean

資料盤是否隨執行個體釋放。

取值:

  • true(預設值):資料盤隨執行個體釋放。

  • false:資料盤不隨執行個體釋放。

SnapshotId

String

建立資料盤使用的快照。

指定該參數後,參數Size會被忽略,實際建立的雲端硬碟大小為指定的快照的大小。

說明

不能使用2013年07月15日之前建立的快照,請求會報錯被拒絕。

Encrypted

Boolean

資料盤是否加密。

取值:

  • true:加密。

  • false(預設值):不加密。

KmsKeyId

String

資料盤對應的KMS密鑰ID。

InternetChargeType

String

網路計費類型。

取值:

  • PayByBandwidth:按固定頻寬計費。

  • PayByTraffic:按使用流量計費。

說明

按使用流量計費模式下的出入頻寬峰值都是頻寬上限,不作為業務承諾指標。當出現資源爭搶時,頻寬峰值可能會受到限制。如果您的業務需要有頻寬的保障,請使用按固定頻寬計費模式。

PerformanceLevel

String

建立ESSD雲端硬碟作為資料盤使用時,設定雲端硬碟的效能等級。

取值:

  • PL0(預設):單盤最高隨機讀寫IOPS 1萬。

  • PL1:單盤最高隨機讀寫IOPS 5萬。

  • PL2:單盤最高隨機讀寫IOPS 10萬。

  • PL3:單盤最高隨機讀寫IOPS 100萬。

Tag文法

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

Tag屬性

屬性名稱

類型

必須

允許更新

描述

約束

Key

String

標籤鍵。

長度為1~128個字元,不能以aliyunacs:開頭,不能包含http://https://

Value

String

標籤值。

長度為0~128個字元,不能以aliyunacs:開頭,不能包含http://https://

DataDiskConfig文法

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

DataDiskConfig屬性

屬性名稱

類型

必須

允許更新

描述

約束

DiskCategory

String

執行個體資料盤資訊。

SystemDiskConfig文法

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

SystemDiskConfig屬性

屬性名稱

類型

必須

允許更新

描述

約束

DiskCategory

String

執行個體系統硬碟資訊。

ResourcePoolOptions文法

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

ResourcePoolOptions屬性

屬性名稱

類型

必須

允許更新

描述

約束

Strategy

String

資源集區包括彈性保障服務或容量預定服務生效後產生的私人池以及公用池,供執行個體啟動時選擇。

取值範圍:

  • PrivatePoolFirst:私人池優先。選擇此種策略時, 當指定了 ResourcePoolOptions.PrivatePoolIds,優先使用指定的私人池。如果未指定私人池或指定的私人池容量不足,將自動匹配開放類型的私人池。如果沒有合格私人池,則使用公用池建立執行個體。

  • PrivatePoolOnly:僅限私人池。選擇此種策略時,必須指定 ResourcePoolOptions.PrivatePoolIds。如果指定的私人池容量不足,則執行個體會啟動失敗。

  • PublicPoolOnly:使用公用池建立執行個體。

預設值:PublicPoolOnly。

PrivatePoolIds

List

私人池 ID列表。

即彈性保障服務 ID 或容量預定服務 ID。該參數只能傳入 Target 模式私人池 ID。最多支援配置20個私人池。

傳回值

Fn::GetAtt

  • AutoProvisioningGroupId:彈性供應組的ID。

  • AutoProvisioningGroupName:彈性供應組的名稱。

樣本

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"
        ]
      }
    }
  }
}