全部產品
Search
文件中心

Resource Orchestration Service:ALIYUN::ECS::Instance

更新時間:Feb 06, 2026

ALIYUN::ECS::Instance類型用於建立ECS執行個體。

重要

本資源已停止迭代更新,建議您使用 ALIYUN::ECS::InstanceGroup 資源。

文法

{
  "Type": "ALIYUN::ECS::Instance",
  "Properties": {
    "DedicatedHostId": String,
    "Period": Number,
    "AutoRenew": String,
    "RamRoleName": String,
    "IoOptimized": String,
    "InternetChargeType": String,
    "PrivateIpAddress": String,
    "KeyPairName": String,
    "SystemDiskDiskName": String,
    "PeriodUnit": String,
    "Description": String,
    "Tags": List,
    "HostName": String,
    "AutoRenewPeriod": Number,
    "ImageId": String,
    "ResourceGroupId": String,
    "InstanceChargeType": String,
    "VSwitchId": String,
    "Password": String,
    "PasswordInherit": Boolean,
    "InstanceType": String,
    "SystemDiskCategory": String,
    "SubscriptionDeletionForce": Boolean,
    "UserData": String,
    "SystemDiskSize": Number,
    "ZoneId": String,
    "InternetMaxBandwidthOut": Integer,
    "VpcId": String,
    "SpotStrategy": String,
    "InstanceName": String,
    "DeletionProtection": Boolean,
    "DeploymentSetId": String,
    "SecurityGroupIds": List,
    "SecurityGroupId": String,
    "SecurityEnhancementStrategy": String,
    "SpotPriceLimit": String,
    "HpcClusterId": String,
    "AllocatePublicIP": Boolean,
    "SystemDiskDescription": String,
    "SystemDiskPerformanceLevel": String,
    "DiskMappings": List,
    "SpotInterruptionBehavior": String,
    "ZoneIds": List,
    "SpotDuration": Integer,
    "CreditSpecification": String,
    "PrivatePoolOptions": Map,
    "StorageSetId": String,
    "HttpTokens": String,
    "HttpEndpoint": String,
    "Tenancy": String,
    "StorageSetPartitionNumber": Integer,
    "DeploymentSetGroupNo": Integer,
    "Affinity": String,
    "UseAdditionalService": Boolean,
    "ImageFamily": String
  }
}

屬性

屬性名稱

類型

必須

允許更新

描述

約束

ResourceGroupId

String

資源群組ID。

SpotInterruptionBehavior

String

搶佔執行個體中斷模式。

目前僅支援Terminate(預設)直接釋放執行個體。

ZoneIds

List

可用性區域列表。

僅在控制台選取參數時生效。

SpotDuration

Integer

搶佔式執行個體的保留時間長度。

取值範圍:0~6。

單位:小時。

  • 取值為0,則為無保護期模式。

  • 保留時間長度2~6正在邀測中,如需開通請提交工單。

  • 預設值為1。

SecurityGroupIds

List

安全性群組ID列表。

SecurityGroupId和SecurityGroupIds僅能指定其中一個。

ImageId

String

鏡像ID。包括公用鏡像、自訂鏡像和雲市場鏡像。

支援通過模糊的方式指定公用鏡像ID,無需指定一個完整的公用鏡像ID。例如:

  • 指定ubuntu,最終會匹配ubuntu16_0402_64_20G_alibase_20170818.vhd。

  • 指定ubuntu_14,最終會匹配ubuntu_14_0405_64_20G_alibase_20170824.vhd。

  • 指定ubuntu*14*32,最終會匹配ubuntu_14_0405_32_40G_alibase_20170711.vhd。

  • 指定ubuntu_16_0402_32,最終會匹配ubuntu_16_0402_32_40G_alibase_20170711.vhd。

InstanceType

String

ECS執行個體規格。

關於ECS執行個體規格的更多資訊,請參見執行個體規格類型系列

SecurityGroupId

String

安全性群組ID。

SecurityGroupId和SecurityGroupIds僅能指定其中一個。

SecurityEnhancementStrategy

String

是否開啟安全強化。

取值:

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

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

Description

String

描述資訊。

長度為2~256個字元。

InstanceName

String

執行個體名稱。

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

如果沒有指定該屬性,預設值為執行個體的InstanceId。

Password

String

ECS執行個體登入密碼。

長度為8~30個字元。必須同時包含大寫英文字母、小寫英文字母、數字和特殊字元中至少三種,支援特殊字元:( ) ' ~ ! @ # $ % ^ & * - + = | { } [ ] : ; < > , . ? / -。如果指定該屬性,請使用HTTPS協議調用API,以避免密碼泄露。

PasswordInherit

Boolean

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

取值:

  • true:使用。

  • false(預設值):不使用。

說明

使用該屬性時,Password必須為空白,同時您需要確保使用的鏡像已經設定了密碼。

HostName

String

雲端服務器的主機名稱。

最小長度為2個字元。半形句號(.)和短劃線(-)不能作為主機名稱的首尾字元,且不能連續使用。

  • Windows平台最大長度為15個字元,支援英文字母、數字或短劃線(-)。不支援半形句號(.),不能全是數字。

  • 其它(Linux等)平台最大長度為30個字元,以半形句號(.)間隔,每段可以由英文字母、數字和短劃線(-)組成。

AllocatePublicIP

Boolean

是否分配公網IP。

取值:

  • true(預設值):分配公網IP。

  • false:不分配公網IP。

說明

如果InternetMaxBandwidthOut取值大於0,則會分配公網IP。

PrivateIpAddress

String

在專用網路環境下,指定的內網IP。

IP地址不能與專用網路下的其它執行個體重複。

InternetChargeType

String

訪問公網計費方式。

取值:

  • PayByBandwidth:按固定頻寬計費。

  • PayByTraffic(預設值):按流量計費。

InternetMaxBandwidthOut

Integer

公網出頻寬最大值。

取值範圍:0~100。

預設值:0。

單位:Mbps。

IoOptimized

String

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

取值:

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

  • optimized(預設值):建立I/O最佳化執行個體。

DiskMappings

List

需要掛載的資料盤。

最多支援16塊資料盤。

更多資訊,請參見DiskMappings文法DiskMappings屬性

SystemDiskCategory

String

系統硬碟類型。

取值:

  • cloud:普通雲端硬碟。

  • cloud_ssd:SSD雲端硬碟。

  • cloud_efficiency:高效雲端硬碟。

  • cloud_essd:ESSD雲端硬碟。

  • ephemeral_ssd:本地SSD盤。

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

SystemDiskDescription

String

系統硬碟描述資訊。

SystemDiskDiskName

String

系統硬碟名稱。

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

SystemDiskSize

Number

系統硬碟大小。

取值範圍:20~500。

單位:GB。

如果使用自訂鏡像建立系統硬碟,需要保證系統硬碟大於自訂鏡像大小。

Tags

List

使用者自訂標籤。

最多支援20個標籤,格式:[{"Key": "tagKey", "Value": "tagValue"},{"Key": "tagKey2", "Value": "tagValue2"}]

更多資訊,請參見Tags文法Tags屬性

UserData

String

建立ECS執行個體時傳遞的使用者資料。

內容需要限制在16 KB以內,不需要使用Base64轉碼,特殊字元需要使用反斜線(\)轉義。

ZoneId

String

可用性區域ID。

HpcClusterId

String

執行個體所屬的HPC叢集ID。

VpcId

String

專用網路ID。

VSwitchId

String

交換器ID。

InstanceChargeType

String

ECS執行個體付費類型。

取值:

  • PrePaid:預付費。如果指定PrePaid,則必須確保餘額充足,否則會導致執行個體建立失敗。

  • PostPaid(預設值):隨用隨付。

Period

Number

付費周期。

當InstanceChargeType取值為PrePaid時,Period為必選屬性;當InstanceChargeType取值為PostPaid時,Period為可選屬性。

KeyPairName

String

ECS執行個體綁定的金鑰組名稱。

當執行個體類型為Windows時,請忽略該屬性;當執行個體類型為Linux時,密碼登入方式會被初始化為禁止。為提高執行個體安全性,建議您使用金鑰組的串連方式。

RamRoleName

String

執行個體RAM角色名稱。

更多資訊,請參見CreateRoleListRoles

SpotPriceLimit

String

執行個體的每小時最高價格。

支援最多3位小數。當SpotStrategy取值為SpotWithPriceLimit時,該屬性生效。

SpotStrategy

String

隨用隨付執行個體的競價策略。

當InstanceChargeType取值為PostPaid時,SpotStrategy為必選屬性。

取值:

  • NoSpot(預設值):正常隨用隨付執行個體。

  • SpotWithPriceLimit:上限價格的競價執行個體。

  • SpotAsPriceGo:系統自動出價,最高不超過隨用隨付價格。

DedicatedHostId

String

ECS執行個體建立指定Dedicated Host上。

您可以通過調用DescribeDedicatedHosts介面查詢Dedicated HostID列表

。由於Dedicated Host不支援建立搶佔式執行個體,指定DedicatedHostId後,請求中的SpotStrategy和SpotPriceLimit設定將被自動忽略。

PeriodUnit

String

購買資源的時間長度。

取值:

  • Week:周。

  • Month(預設值):月。

AutoRenewPeriod

Number

每次自動續約的時間長度。

當AutoRenew取值為True時,AutoRenewPeriod為必選屬性。

取值:

  • 當PeriodUnit為Week時,AutoRenewPeriod取值為1、2、3。

  • 當PeriodUnit為Month時,AutoRenewPeriod取值為1、2、3、6、12。

AutoRenew

String

是否自動續約。

取值:

  • True:自動續約。

  • False(預設值):不自動續約。

當InstanceChargeType取值PrePaid時,AutoRenew為必選屬性。

DeletionProtection

Boolean

執行個體釋放保護屬性,指定是否支援通過控制台或DeleteInstance介面釋放執行個體。

取值:

  • true:開啟執行個體釋放保護。

  • false(預設):關閉執行個體釋放保護。

說明

該屬性僅適用於隨用隨付執行個體,且只能限制手動釋放操作,對系統釋放操作不生效。

DeploymentSetId

String

部署集ID。

SystemDiskPerformanceLevel

String

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

取值:

  • PL0:單盤最高隨機讀寫IOPS為1萬。

  • PL1(預設值):單盤最高隨機讀寫IOPS為5萬。

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

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

關於如何選擇ESSD效能等級,請參見ESSD雲端硬碟

CreditSpecification

String

設定突發效能執行個體的運行模式。

取值:

PrivatePoolOptions

Map

執行個體啟動的私人池容量選項。

更多資訊,請參考PrivatePoolOptions屬性

StorageSetId

String

儲存集ID。

HttpTokens

String

訪問執行個體中繼資料時是否強制使用加固模式(IMDSv2)。

取值:

  • optional(預設值):不強制使用。

  • required:強制使用。設定該取值後,普通模式無法訪問執行個體中繼資料。

說明

有關訪問執行個體中繼資料的模式,請參見執行個體中繼資料

SubscriptionDeletionForce

Boolean

該選項僅適用於訂用帳戶執行個體。對於訂用帳戶執行個體,如果此選項為 true,則在刪除前會將執行個體轉換為隨用隨付執行個體;如果為 false,則不會執行強制移除。此操作會產生額外費用,請謹慎選擇。

HttpEndpoint

String

是否啟用執行個體中繼資料的訪問通道。

取值範圍:

  • enabled(預設值):啟用。

  • disabled:禁用。

說明

有關執行個體中繼資料的資訊,請參見執行個體中繼資料

Tenancy

String

是否在Dedicated Host上建立執行個體。

取值:

  • default(預設值):建立非Dedicated Host執行個體。

  • host:建立Dedicated Host執行個體。若您不指定DedicatedHostId,則由阿里雲自動選擇Dedicated Host放置執行個體。

StorageSetPartitionNumber

Integer

儲存集中的最大分區數量。

取值範圍:大於等於2。

DeploymentSetGroupNo

Integer

如果您設定的部署集對應的策略為部署集組高可用策略(AvailabilityGroup),可以通過該參數指定執行個體在部署集中的分組號。

取值範圍:1~7。

Affinity

String

Dedicated Host執行個體是否與Dedicated Host關聯。

取值:

  • default(預設值):執行個體不與Dedicated Host關聯。已啟用節省停機模式的執行個體,停機後再次啟動時,若原Dedicated Host可用資源不足,則執行個體被放置在自動部署資源集區的其他Dedicated Host上。

  • host:執行個體與Dedicated Host關聯。已啟用節省停機模式的執行個體,停機後再次啟動時,仍放置在原Dedicated Host上。若原Dedicated Host可用資源不足,則執行個體重啟失敗。

UseAdditionalService

Boolean

是否使用阿里雲提供的虛擬機器系統配置(Windows:NTP、KMS;Linux:NTP、YUM)。

取值:

  • true

  • false

ImageFamily

String

鏡像族系名稱。

通過設定該參數來擷取當前鏡像族系內最新可用鏡像來建立執行個體。

  • 設定了參數ImageId,則不能設定該參數。

  • 未設定參數ImageId,但指定的LaunchTemplateIdLaunchTemplateName對應的啟動模板設定了ImageId,則不能設定該參數。

  • 未設定ImageId,且指定的LaunchTemplateIdLaunchTemplateName對應的啟動模板未設定ImageId,則可以設定該參數。

  • 未設定ImageId,且未設定LaunchTemplateIdLaunchTemplateName參數,則可以設定該參數。

說明

阿里雲官方鏡像關聯的鏡像族系資訊請參見公用鏡像

DiskMappings文法

"DiskMappings": [
  {
    "Category": String,
    "DiskName": String,
    "Description": String,
    "Device": String,
    "SnapshotId": String,
    "PerformanceLevel": String,
    "Size": String
  }
]

DiskMappings屬性

屬性名稱

類型

必須

允許更新

描述

約束

Size

String

資料盤大小。

取值範圍:20~500。

單位:GB。

Category

String

資料盤類型。

取值:

  • cloud:普通雲端硬碟。

  • cloud_ssd:SSD雲端硬碟。

  • cloud_essd:ESSD雲端硬碟。

  • cloud_efficiency:高效雲端硬碟。

  • ephemeral_ssd:本地SSD盤。

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

如果自訂鏡像已包含了一個資料盤,那麼建立ECS執行個體時,若要在ROS模板中指定資料盤類型,可以將Category指定為需要的資料盤類型。例如:

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Resources": {
    "Instance": {
      "Type": "ALIYUN::ECS::Instance",
      "Properties": {
        "InstanceName": "rostest",
        "ImageId": "m-2ze5ysugu8ss7nxr****",
        "InstanceType": "ecs.g6e.large",
        "Password": "Ros1****",
        "IoOptimized": "optimized",
        "VSwitchId": "vsw-2zej7phc6euuelo8l****",
        "VpcId": "vpc-2zebbi27bn7w42n30****",
        "SecurityGroupId": "sg-2ze5bdyyg7sfrcv6****",
        "SystemDiskCategory": "cloud_essd",
        "DiskMappings": [
          {
            "Category": "cloud_essd",
            "Size": 40,
            "Device": "/dev/xvdb"
          }
        ]
      }
    }
  }
}
                                

DiskName

String

資料盤名稱。

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

Description

String

描述資訊。

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

Device

String

掛載點。

PerformanceLevel

String

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

取值:

  • PL1(預設值):單盤最高隨機讀寫IOPS為5萬。

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

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

關於如何選擇ESSD效能等級,請參見ESSD雲端硬碟

SnapshotId

String

資料盤使用的快照ID。

Tags文法

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

Tags屬性

屬性名稱

類型

必須

允許更新

描述

約束

Key

String

標籤鍵。

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

Value

String

標籤值。

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

PrivatePoolOptions文法

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

PrivatePoolOptions屬性

屬性名稱

類型

必須

允許更新

描述

約束

Id

String

私人池ID。即彈性保障服務ID或容量預定服務ID。

MatchCriteria

String

彈性保障服務或容量預定服務在生效後會產生私人池容量,供執行個體啟動時選擇。

取值:

  • Open:開放模式。將自動匹配開放類型的私人池容量。如果沒有合格私人池容量,則使用公用池資源啟動。該模式下無需設定PrivatePoolOptions.Id參數。

  • Target:指定模式。使用指定的私人池容量啟動執行個體,如果該私人池容量不可用,則執行個體會啟動失敗。該模式下必須指定私人池ID,即PrivatePoolOptions.Id參數為必填項。

  • None(預設值):不使用模式。執行個體啟動將不使用私人池容量。

以下任一情境,執行個體啟動的私人池容量選項只能取值None或不傳值。

  • 建立搶佔式執行個體。

  • 建立傳統網路類型的ECS執行個體。

  • 在Dedicated HostDDH上建立ECS執行個體。

傳回值

Fn::GetAtt

  • InstanceId:執行個體ID。由系統產生,執行個體的全域唯一標識。

  • PrivateIp:VPC類型執行個體的私網IP地址。

  • InnerIp:Classic類型執行個體的內網IP地址。

  • PublicIp:Classic類型執行個體的公網IP地址。

  • ZoneId:可用性區域ID。

  • HostName:雲端服務器的主機名稱。

  • PrimaryNetworkInterfaceId:主網卡ID。

  • SecurityGroupIds:已建立執行個體的安全性群組ID列表。

樣本

情境 1 :建立兩台ECS執行個體並實現免密登入。

快速建立

ROSTemplateFormatVersion: '2015-09-01'
Description: Creates VPC ECS instance
Metadata: {}
Parameters:
  VpcId:
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
    Type: String
    Description:
      en: Please search the ID starting with (vpc-xxx) from console-Virtual Private Cloud
      zh-cn: 現有專用網路的執行個體ID
    Label:
      en: VPC ID
      zh-cn: Virtual Private Cloud執行個體ID
  VSwitchZoneId:
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
    Type: String
    Description:
      zh-cn: 可用性區域ID。<br><b>註: <font color='blue'>選擇前請確認該可用性區域是否支援建立ECS資源的規格,建議與其他交換器可用性區域不同</font></b>
      en: Availability Zone ID.<br><b>note:<font color='blue'>before selecting, please confirm that the Availability Zone supports the specification of creating ECS resources,which is recommended to be different from other VSwitch Availability Zone</font></b>
    Label:
      zh-cn: 交換器可用性區域
      en: VSwitch Availability Zone
  VSwitchId:
    AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
    AssociationPropertyMetadata:
      VpcId: ${VpcId}
      ZoneId: ${VSwitchZoneId}
    Type: String
    Description:
      en: Instance ID of existing business network switches, console-Virtual Private Cloud-VSwitches under query
      zh-cn: 現有業務網路交換器的執行個體ID
    Label:
      en: VSwitch ID
      zh-cn: 交換器執行個體ID
  SecurityGroupId:
    Type: String
    AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
    AssociationPropertyMetadata:
      VpcId: ${VpcId}
    Description:
      en: Please search the business security group ID starting with(sg-xxx)from console-ECS-Network & Security
      zh-cn: 現有業務安全性群組的執行個體ID
    Label:
      en: Business Security Group ID
      zh-cn: 業務安全性群組ID
  InstanceType:
    Type: String
    Description:
      zh-cn: 填寫VSwitch可用性區域下可使用的規格。
      en: Fill in the specifications that can be used under the VSwitch availability zone.
    Label:
      zh-cn: 執行個體規格
      en: Instance Type
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      ZoneId: ${VSwitchZoneId}
  SystemDiskCategory:
    Type: String
    AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
    AssociationPropertyMetadata:
      ZoneId: ${VSwitchZoneId}
      InstanceType: ${InstanceType}
    Label:
      en: System Disk Type
      zh-cn: 系統硬碟類型
    Description:
      en: '<font color=''blue''><b>Optional values:</b></font><br>[cloud_efficiency: <font color=''green''>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color=''green''>SSD Cloud Disk</font>]<br>[cloud_essd: <font color=''green''>ESSD Cloud Disk</font>]<br>[cloud: <font color=''green''>Cloud Disk</font>]<br>[ephemeral_ssd: <font color=''green''>Local SSD Cloud Disk</font>]'
      zh-cn: '<font color=''blue''><b>可選值:</b></font><br>[cloud_efficiency: <font color=''green''>高效雲端硬碟</font>]<br>[cloud_ssd: <font color=''green''>SSD雲端硬碟</font>]<br>[cloud_essd: <font color=''green''>ESSD雲端硬碟</font>]<br>[cloud: <font color=''green''>普通雲端硬碟</font>]<br>[ephemeral_ssd: <font color=''green''>本地SSD盤</font>]'
  SystemDiskSize:
    Default: 40
    Type: Number
    Description:
      zh-cn: 系統硬碟大小, 取值範圍:[40, 500], 單位:GB。
      en: 'System disk size, range of values: 40-500, units: GB.'
    Label:
      zh-cn: 系統硬碟空間
      en: System Disk Space
Resources:
  OpsEcsInstance:
    Type: ALIYUN::ECS::Instance
    Properties:
      HostName: OpsEcsInstance
      UserData:
        Fn::Sub:
          - |
            #!/bin/bash
            RootPassword=${RootPassword}
            ProdIP=${ProdIP}
            SSHConfig() {
            echo '[ ! -f /root/.ssh/id_rsa.pub ] && ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa &>/dev/null' >> /tmp/auto_ssh.sh
            echo 'while read line;do' >> /tmp/auto_ssh.sh
            echo '        ip=`echo $line | cut -d " " -f1`' >> /tmp/auto_ssh.sh
            echo '        user_name=`echo $line | cut -d " " -f2`' >> /tmp/auto_ssh.sh
            echo '        pass_word=`echo $line | cut -d " " -f3`' >> /tmp/auto_ssh.sh
            echo 'expect <<EOF' >> /tmp/auto_ssh.sh
            echo '        spawn ssh-copy-id -i /root/.ssh/id_rsa.pub $user_name@$ip' >> /tmp/auto_ssh.sh
            echo '        expect {' >> /tmp/auto_ssh.sh
            echo '                  "yes/no" { send "yes\n";exp_continue}' >> /tmp/auto_ssh.sh
            echo '                  "password" { send "$pass_word\n"}' >> /tmp/auto_ssh.sh
            echo '        }' >> /tmp/auto_ssh.sh
            echo '        expect eof' >> /tmp/auto_ssh.sh
            echo 'EOF' >> /tmp/auto_ssh.sh
            echo 'done < /tmp/host_ip.txt' >> /tmp/auto_ssh.sh
            }
            SetHostsConfig() {
            echo "`ifconfig eth0 | awk '/inet /{print $2}'` root ${RootPassword}" >> /tmp/host_ip.txt
            echo "${ProdIP} root ${RootPassword}" >> /tmp/host_ip.txt
            sh /tmp/auto_ssh.sh
            }
            main() {
            yum install -y expect
            SSHConfig
            SetHostsConfig
            rm -rf /tmp/host_ip.txt
            }
            main
          - ProdIP:
              Fn::GetAtt:
                - ProdEcsInstance
                - PrivateIp
            RootPassword: Admin@123!
      VpcId:
        Ref: VpcId
      SecurityGroupId:
        Ref: SecurityGroupId
      VSwitchId:
        Ref: VSwitchId
      ImageId: centos_7
      AllocatePublicIP: false
      InstanceType:
        Ref: InstanceType
      SystemDiskSize: 40
      SystemDiskCategory:
        Ref: SystemDiskCategory
      Password: Admin@123!
  ProdEcsInstance:
    Type: ALIYUN::ECS::Instance
    Properties:
      HostName: ProdEcsInstance
      SystemDiskCategory:
        Ref: SystemDiskCategory
      VpcId:
        Ref: VpcId
      SecurityGroupId:
        Ref: SecurityGroupId
      SystemDiskSize: 40
      ImageId: centos_7
      VSwitchId:
        Ref: VSwitchId
      Password: Admin@123!
      InstanceType:
        Ref: InstanceType
      AllocatePublicIP: false
Outputs: {}                    
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": "Creates VPC ECS instance",
  "Metadata": {},
  "Parameters": {
    "VpcId": {
      "AssociationProperty": "ALIYUN::ECS::VPC::VPCId",
      "Type": "String",
      "Description": {
        "en": "Please search the ID starting with (vpc-xxx) from console-Virtual Private Cloud",
        "zh-cn": "現有專用網路的執行個體ID"
      },
      "Label": {
        "en": "VPC ID",
        "zh-cn": "Virtual Private Cloud執行個體ID"
      }
    },
    "VSwitchZoneId": {
      "AssociationProperty": "ALIYUN::ECS::Instance:ZoneId",
      "Type": "String",
      "Description": {
        "zh-cn": "可用性區域ID。<br><b>註: <font color='blue'>選擇前請確認該可用性區域是否支援建立ECS資源的規格,建議與其他交換器可用性區域不同</font></b>",
        "en": "Availability Zone ID.<br><b>note:<font color='blue'>before selecting, please confirm that the Availability Zone supports the specification of creating ECS resources,which is recommended to be different from other VSwitch Availability Zone</font></b>"
      },
      "Label": {
        "zh-cn": "交換器可用性區域",
        "en": "VSwitch Availability Zone"
      }
    },
    "VSwitchId": {
      "AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
      "AssociationPropertyMetadata": {
        "VpcId": "${VpcId}",
        "ZoneId": "${VSwitchZoneId}"
      },
      "Type": "String",
      "Description": {
        "en": "Instance ID of existing business network switches, console-Virtual Private Cloud-VSwitches under query",
        "zh-cn": "現有業務網路交換器的執行個體ID"
      },
      "Label": {
        "en": "VSwitch ID",
        "zh-cn": "交換器執行個體ID"
      }
    },
    "SecurityGroupId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::SecurityGroup::SecurityGroupId",
      "AssociationPropertyMetadata": {
        "VpcId": "${VpcId}"
      },
      "Description": {
        "en": "Please search the business security group ID starting with(sg-xxx)from console-ECS-Network & Security",
        "zh-cn": "現有業務安全性群組的執行個體ID"
      },
      "Label": {
        "en": "Business Security Group ID",
        "zh-cn": "業務安全性群組ID"
      }
    },
    "InstanceType": {
      "Type": "String",
      "Description": {
        "zh-cn": "填寫VSwitch可用性區域下可使用的規格。",
        "en": "Fill in the specifications that can be used under the VSwitch availability zone."
      },
      "Label": {
        "zh-cn": "執行個體規格",
        "en": "Instance Type"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "ZoneId": "${VSwitchZoneId}"
      }
    },
    "SystemDiskCategory": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
      "AssociationPropertyMetadata": {
        "ZoneId": "${VSwitchZoneId}",
        "InstanceType": "${InstanceType}"
      },
      "Label": {
        "en": "System Disk Type",
        "zh-cn": "系統硬碟類型"
      },
      "Description": {
        "en": "<font color='blue'><b>Optional values:</b></font><br>[cloud_efficiency: <font color='green'>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color='green'>SSD Cloud Disk</font>]<br>[cloud_essd: <font color='green'>ESSD Cloud Disk</font>]<br>[cloud: <font color='green'>Cloud Disk</font>]<br>[ephemeral_ssd: <font color='green'>Local SSD Cloud Disk</font>]",
        "zh-cn": "<font color='blue'><b>可選值:</b></font><br>[cloud_efficiency: <font color='green'>高效雲端硬碟</font>]<br>[cloud_ssd: <font color='green'>SSD雲端硬碟</font>]<br>[cloud_essd: <font color='green'>ESSD雲端硬碟</font>]<br>[cloud: <font color='green'>普通雲端硬碟</font>]<br>[ephemeral_ssd: <font color='green'>本地SSD盤</font>]"
      }
    },
    "SystemDiskSize": {
      "Default": 40,
      "Type": "Number",
      "Description": {
        "zh-cn": "系統硬碟大小, 取值範圍:[40, 500], 單位:GB。",
        "en": "System disk size, range of values: 40-500, units: GB."
      },
      "Label": {
        "zh-cn": "系統硬碟空間",
        "en": "System Disk Space"
      }
    }
  },
  "Resources": {
    "OpsEcsInstance": {
      "Type": "ALIYUN::ECS::Instance",
      "Properties": {
        "HostName": "OpsEcsInstance",
        "UserData": {
          "Fn::Sub": [
            "#!/bin/bash\nRootPassword=${RootPassword}\nProdIP=${ProdIP}\nSSHConfig() {\necho '[ ! -f /root/.ssh/id_rsa.pub ] && ssh-keygen -t rsa -P \"\" -f ~/.ssh/id_rsa &>/dev/null' >> /tmp/auto_ssh.sh\necho 'while read line;do' >> /tmp/auto_ssh.sh\necho '        ip=`echo $line | cut -d \" \" -f1`' >> /tmp/auto_ssh.sh\necho '        user_name=`echo $line | cut -d \" \" -f2`' >> /tmp/auto_ssh.sh\necho '        pass_word=`echo $line | cut -d \" \" -f3`' >> /tmp/auto_ssh.sh\necho 'expect <<EOF' >> /tmp/auto_ssh.sh\necho '        spawn ssh-copy-id -i /root/.ssh/id_rsa.pub $user_name@$ip' >> /tmp/auto_ssh.sh\necho '        expect {' >> /tmp/auto_ssh.sh\necho '                  \"yes/no\" { send \"yes\\n\";exp_continue}' >> /tmp/auto_ssh.sh\necho '                  \"password\" { send \"$pass_word\\n\"}' >> /tmp/auto_ssh.sh\necho '        }' >> /tmp/auto_ssh.sh\necho '        expect eof' >> /tmp/auto_ssh.sh\necho 'EOF' >> /tmp/auto_ssh.sh\necho 'done < /tmp/host_ip.txt' >> /tmp/auto_ssh.sh\n}\nSetHostsConfig() {\necho \"`ifconfig eth0 | awk '/inet /{print $2}'` root ${RootPassword}\" >> /tmp/host_ip.txt\necho \"${ProdIP} root ${RootPassword}\" >> /tmp/host_ip.txt\nsh /tmp/auto_ssh.sh\n}\nmain() {\nyum install -y expect\nSSHConfig\nSetHostsConfig\nrm -rf /tmp/host_ip.txt\n}\nmain\n",
            {
              "ProdIP": {
                "Fn::GetAtt": [
                  "ProdEcsInstance",
                  "PrivateIp"
                ]
              },
              "RootPassword": "Admin@123!"
            }
          ]
        },
        "VpcId": {
          "Ref": "VpcId"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroupId"
        },
        "VSwitchId": {
          "Ref": "VSwitchId"
        },
        "ImageId": "centos_7",
        "AllocatePublicIP": false,
        "InstanceType": {
          "Ref": "InstanceType"
        },
        "SystemDiskSize": 40,
        "SystemDiskCategory": {
          "Ref": "SystemDiskCategory"
        },
        "Password": "Admin@123!"
      }
    },
    "ProdEcsInstance": {
      "Type": "ALIYUN::ECS::Instance",
      "Properties": {
        "HostName": "ProdEcsInstance",
        "SystemDiskCategory": {
          "Ref": "SystemDiskCategory"
        },
        "VpcId": {
          "Ref": "VpcId"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroupId"
        },
        "SystemDiskSize": 40,
        "ImageId": "centos_7",
        "VSwitchId": {
          "Ref": "VSwitchId"
        },
        "Password": "Admin@123!",
        "InstanceType": {
          "Ref": "InstanceType"
        },
        "AllocatePublicIP": false
      }
    }
  },
  "Outputs": {}
}                 

情境 2 :建立綁定了多個私網地址的ECS

快速建立

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 建立ECS執行個體,配置VPC、安全性群組、多IP地址、系統硬碟及網路介面,支援自訂執行個體規格、鏡像和網路設定。
  en: Create an ECS instance, configure VPC, security group, multiple IP addresses, system disk and network interface, and support customizing instance specifications, mirroring and network settings.
Parameters:
  EcsInstanceType:
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      ZoneId: VSwitchZoneId
    Type: String
    Description:
      zh-cn: <font color='blue'><b>1.選擇機型前請先確認當前可用性區域下該機型是否有貨,部分機型需要提前報備</b></font><br><font color='blue'><b>2.可選機型列表</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB 內網頻寬1Gbps 內網收發包30萬PPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB 內網頻寬1.5Gbps 內網收發包50萬PPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB 內網頻寬2.5Gbps 內網收發包80萬PPS</font>]
      en: <font color='blue'><b>1.Before selecting the model please confirm that the current available zone under the model is in stock, some models need to be reported in advance</b></font><br><font color='blue'><b>2.List of optional models</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB Intranet bandwidth1Gbps In-grid sending and receiving packages30MillionPPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB Intranet bandwidth1.5Gbps In-grid sending and receiving packages50MillionPPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB Intranet bandwidth2.5Gbps In-grid sending and receiving packages80MillionPPS</font>]
    Label:
      zh-cn: 執行個體規格
      en: Instance Type
  VSwitchZoneId:
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
    Type: String
    Description:
      zh-cn: 可用性區域ID,<br><b>註: <font color='blue'>選擇可用性區域前請確認該可用性區域是否支援建立ECS資源的規格</font></b>
      en: Availability Zone ID,<br><b>note: <font color='blue'>Before selecting, please confirm that the Availability Zone supports the specification of creating ECS resources</font></b>
    Label:
      zh-cn: 交換器可用性區域
      en: VSwitch Availability Zone
  EcsSystemDiskSize:
    Default: 40
    Type: Number
    Description:
      zh-cn: 系統硬碟大小, 取值範圍:[40, 500], 單位:GB。
      en: 'System disk size, range of values: 40-500, units: GB.'
    Label:
      zh-cn: 系統硬碟空間
      en: System Disk Space
  EcsPassword:
    Description:
      zh-cn: 伺服器登入密碼,長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)。
      en: Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).
    Type: String
    Label:
      zh-cn: 執行個體密碼
      en: Instance Password
    NoEcho: true
    AssociationProperty: ALIYUN::ECS::Instance::Password
    ConstraintDescription:
      zh-cn: 長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)。
      en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).
  EcsImageId:
    AssociationPropertyMetadata:
      InstanceType: ${EcsInstanceType}
      SupportedImageOwnerAlias:
        - system
        - self
        - others
    Description:
      zh-cn: 執行個體鏡像,詳見:<b><a href='https://www.alibabacloud.com/help/document_detail/112977.html' target='_blank'><font color='blue'>尋找鏡像</font></a></b>
      en: 'Instance Image ID. see detail: <b><a href=''https://www.alibabacloud.com/help/doc-detail/112977.html'' target=''_blank''><font color=''blue''>Find the mirror</font></a></b>'
    Default: centos_7_04_64_20G_alibase_201701015.vhd
    Label:
      zh-cn: 鏡像ID
      en: Image ID
    AssociationProperty: ALIYUN::ECS::Image::ImageId
    Type: String
  EcsSystemDiskCategory:
    AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
    AssociationPropertyMetadata:
      LocaleKey: DiskCategory
      InstanceType: ${EcsInstanceType}
    Type: String
    Description:
      zh-cn: '<font color=''blue''><b>可選值:</b></font><br>[cloud_efficiency: <font color=''green''>高效雲端硬碟</font>]<br>[cloud_ssd: <font color=''green''>SSD雲端硬碟</font>]<br>[cloud_essd: <font color=''green''>ESSD雲端硬碟</font>]<br>[cloud: <font color=''green''>普通雲端硬碟</font>]<br>[ephemeral_ssd: <font color=''green''>本地SSD盤</font>]'
      en: '<font color=''blue''><b>Optional values:</b></font><br>[cloud_efficiency: <font color=''green''>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color=''green''>SSD Cloud Disk</font>]<br>[cloud_essd: <font color=''green''>ESSD Cloud Disk</font>]<br>[cloud: <font color=''green''>Cloud Disk</font>]<br>[ephemeral_ssd: <font color=''green''>Local SSD Cloud Disk</font>]'
    Label:
      zh-cn: 系統硬碟類型
      en: System Disk Type
  IpAddressCount:
    Description:
      zh-cn: 取值範圍:1-9。
      en: 'Allowed values: 1~9.'
    Default: 1
    MaxValue: 9
    MinValue: 1
    Label:
      zh-cn: 網卡分配IPv4數量
      en: Number of IPv4 Network Card
    Type: Number
Outputs:
  InstanceId:
    Value:
      Ref: EcsInstance
  EIP:
    Value:
      Fn::GetAtt:
        - Eip
        - EipAddress
  PrimaryPrivateIPAddress:
    Value:
      Fn::GetAtt:
        - EcsInstance
        - PrivateIp
  AddPrivateIPAddressList:
    Value:
      Fn::GetAtt:
        - EcsAssignPrivateIpAddresses
        - PrivateIpAddresses
Resources:
  EcsAssignPrivateIpAddresses:
    Type: ALIYUN::ECS::AssignPrivateIpAddresses
    Properties:
      NetworkInterfaceId:
        Ref: EcsENI
      SecondaryPrivateIpAddressCount:
        Ref: IpAddressCount
    DependsOn:
      - EcsENI
  EcsENI:
    Type: ALIYUN::ECS::NetworkInterface
    Properties:
      SecurityGroupId:
        Ref: EcsSecurityGroup
      VSwitchId:
        Ref: EcsVSwitch
  EcsSecurityGroup:
    Type: ALIYUN::ECS::SecurityGroup
    Properties:
      VpcId:
        Ref: EcsVpc
      SecurityGroupName:
        Fn::Join:
          - _
          - - StackId
            - Ref: ALIYUN::StackId
  Eip:
    Type: ALIYUN::VPC::EIP
    Properties:
      InternetChargeType: PayByTraffic
      InstanceChargeType: Postpaid
  EcsVSwitch:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      VSwitchName:
        Fn::Join:
          - _
          - - StackId
            - Ref: ALIYUN::StackId
      VpcId:
        Ref: EcsVpc
      CidrBlock: 192.168.0.0/24
      ZoneId:
        Ref: VSwitchZoneId
  EcsEniAttachment:
    Type: ALIYUN::ECS::NetworkInterfaceAttachment
    Properties:
      InstanceId:
        Ref: EcsInstance
      NetworkInterfaceId:
        Ref: EcsENI
    DependsOn:
      - EcsInstance
      - EipAssociation
  EcsInstance:
    Type: ALIYUN::ECS::Instance
    Properties:
      SystemDiskCategory:
        Ref: EcsSystemDiskCategory
      VpcId:
        Ref: EcsVpc
      SecurityGroupId:
        Ref: EcsSecurityGroup
      SystemDiskSize:
        Ref: EcsSystemDiskSize
      ImageId:
        Ref: EcsImageId
      AllocatePublicIP: false
      InstanceChargeType: PostPaid
      VSwitchId:
        Ref: EcsVSwitch
      IoOptimized: optimized
      Password:
        Ref: EcsPassword
      InstanceType:
        Ref: EcsInstanceType
  EcsVpc:
    Type: ALIYUN::ECS::VPC
    Properties:
      VpcName:
        Fn::Join:
          - '-'
          - - StackId
            - Ref: ALIYUN::StackId
      CidrBlock: 192.168.0.0/16
  EipAssociation:
    Type: ALIYUN::VPC::EIPAssociation
    Properties:
      InstanceId:
        Ref: EcsENI
      AllocationId:
        Ref: Eip
      Mode: NAT
    DependsOn:
      - EcsAssignPrivateIpAddresses
      - Eip
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - VSwitchZoneId
          - IpAddressCount
        Label:
          default:
            zh-cn: 專用網路
            en: VPC
      - Parameters:
          - EcsInstanceType
          - EcsImageId
          - EcsSystemDiskCategory
          - EcsSystemDiskSize
          - EcsPassword
        Label:
          default:
            zh-cn: 雲端服務器
            en: ECS
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "建立ECS執行個體,配置VPC、安全性群組、多IP地址、系統硬碟及網路介面,支援自訂執行個體規格、鏡像和網路設定。",
    "en": "Create an ECS instance, configure VPC, security group, multiple IP addresses, system disk and network interface, and support customizing instance specifications, mirroring and network settings."
  },
  "Parameters": {
    "EcsInstanceType": {
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "ZoneId": "VSwitchZoneId"
      },
      "Type": "String",
      "Description": {
        "zh-cn": "<font color='blue'><b>1.選擇機型前請先確認當前可用性區域下該機型是否有貨,部分機型需要提前報備</b></font><br><font color='blue'><b>2.可選機型列表</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB 內網頻寬1Gbps 內網收發包30萬PPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB 內網頻寬1.5Gbps 內網收發包50萬PPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB 內網頻寬2.5Gbps 內網收發包80萬PPS</font>]",
        "en": "<font color='blue'><b>1.Before selecting the model please confirm that the current available zone under the model is in stock, some models need to be reported in advance</b></font><br><font color='blue'><b>2.List of optional models</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB Intranet bandwidth1Gbps In-grid sending and receiving packages30MillionPPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB Intranet bandwidth1.5Gbps In-grid sending and receiving packages50MillionPPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB Intranet bandwidth2.5Gbps In-grid sending and receiving packages80MillionPPS</font>]"
      },
      "Label": {
        "zh-cn": "執行個體規格",
        "en": "Instance Type"
      }
    },
    "VSwitchZoneId": {
      "AssociationProperty": "ALIYUN::ECS::Instance:ZoneId",
      "Type": "String",
      "Description": {
        "zh-cn": "可用性區域ID,<br><b>註: <font color='blue'>選擇可用性區域前請確認該可用性區域是否支援建立ECS資源的規格</font></b>",
        "en": "Availability Zone ID,<br><b>note: <font color='blue'>Before selecting, please confirm that the Availability Zone supports the specification of creating ECS resources</font></b>"
      },
      "Label": {
        "zh-cn": "交換器可用性區域",
        "en": "VSwitch Availability Zone"
      }
    },
    "EcsSystemDiskSize": {
      "Default": 40,
      "Type": "Number",
      "Description": {
        "zh-cn": "系統硬碟大小, 取值範圍:[40, 500], 單位:GB。",
        "en": "System disk size, range of values: 40-500, units: GB."
      },
      "Label": {
        "zh-cn": "系統硬碟空間",
        "en": "System Disk Space"
      }
    },
    "EcsPassword": {
      "Description": {
        "zh-cn": "伺服器登入密碼,長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)。",
        "en": "Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)."
      },
      "Type": "String",
      "Label": {
        "zh-cn": "執行個體密碼",
        "en": "Instance Password"
      },
      "NoEcho": true,
      "AssociationProperty": "ALIYUN::ECS::Instance::Password",
      "ConstraintDescription": {
        "zh-cn": "長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)。",
        "en": "Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)."
      }
    },
    "EcsImageId": {
      "AssociationPropertyMetadata": {
        "InstanceType": "${EcsInstanceType}",
        "SupportedImageOwnerAlias": [
          "system",
          "self",
          "others"
        ]
      },
      "Description": {
        "zh-cn": "執行個體鏡像,詳見:<b><a href='https://www.alibabacloud.com/help/document_detail/112977.html' target='_blank'><font color='blue'>尋找鏡像</font></a></b>",
        "en": "Instance Image ID. see detail: <b><a href='https://www.alibabacloud.com/help/doc-detail/112977.html' target='_blank'><font color='blue'>Find the mirror</font></a></b>"
      },
      "Default": "centos_7_04_64_20G_alibase_201701015.vhd",
      "Label": {
        "zh-cn": "鏡像ID",
        "en": "Image ID"
      },
      "AssociationProperty": "ALIYUN::ECS::Image::ImageId",
      "Type": "String"
    },
    "EcsSystemDiskCategory": {
      "AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
      "AssociationPropertyMetadata": {
        "LocaleKey": "DiskCategory",
        "InstanceType": "${EcsInstanceType}"
      },
      "Type": "String",
      "Description": {
        "zh-cn": "<font color='blue'><b>可選值:</b></font><br>[cloud_efficiency: <font color='green'>高效雲端硬碟</font>]<br>[cloud_ssd: <font color='green'>SSD雲端硬碟</font>]<br>[cloud_essd: <font color='green'>ESSD雲端硬碟</font>]<br>[cloud: <font color='green'>普通雲端硬碟</font>]<br>[ephemeral_ssd: <font color='green'>本地SSD盤</font>]",
        "en": "<font color='blue'><b>Optional values:</b></font><br>[cloud_efficiency: <font color='green'>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color='green'>SSD Cloud Disk</font>]<br>[cloud_essd: <font color='green'>ESSD Cloud Disk</font>]<br>[cloud: <font color='green'>Cloud Disk</font>]<br>[ephemeral_ssd: <font color='green'>Local SSD Cloud Disk</font>]"
      },
      "Label": {
        "zh-cn": "系統硬碟類型",
        "en": "System Disk Type"
      }
    },
    "IpAddressCount": {
      "Description": {
        "zh-cn": "取值範圍:1-9。",
        "en": "Allowed values: 1~9."
      },
      "Default": 1,
      "MaxValue": 9,
      "MinValue": 1,
      "Label": {
        "zh-cn": "網卡分配IPv4數量",
        "en": "Number of IPv4 Network Card"
      },
      "Type": "Number"
    }
  },
  "Outputs": {
    "InstanceId": {
      "Value": {
        "Ref": "EcsInstance"
      }
    },
    "EIP": {
      "Value": {
        "Fn::GetAtt": [
          "Eip",
          "EipAddress"
        ]
      }
    },
    "PrimaryPrivateIPAddress": {
      "Value": {
        "Fn::GetAtt": [
          "EcsInstance",
          "PrivateIp"
        ]
      }
    },
    "AddPrivateIPAddressList": {
      "Value": {
        "Fn::GetAtt": [
          "EcsAssignPrivateIpAddresses",
          "PrivateIpAddresses"
        ]
      }
    }
  },
  "Resources": {
    "EcsAssignPrivateIpAddresses": {
      "Type": "ALIYUN::ECS::AssignPrivateIpAddresses",
      "Properties": {
        "NetworkInterfaceId": {
          "Ref": "EcsENI"
        },
        "SecondaryPrivateIpAddressCount": {
          "Ref": "IpAddressCount"
        }
      },
      "DependsOn": [
        "EcsENI"
      ]
    },
    "EcsENI": {
      "Type": "ALIYUN::ECS::NetworkInterface",
      "Properties": {
        "SecurityGroupId": {
          "Ref": "EcsSecurityGroup"
        },
        "VSwitchId": {
          "Ref": "EcsVSwitch"
        }
      }
    },
    "EcsSecurityGroup": {
      "Type": "ALIYUN::ECS::SecurityGroup",
      "Properties": {
        "VpcId": {
          "Ref": "EcsVpc"
        },
        "SecurityGroupName": {
          "Fn::Join": [
            "_",
            [
              "StackId",
              {
                "Ref": "ALIYUN::StackId"
              }
            ]
          ]
        }
      }
    },
    "Eip": {
      "Type": "ALIYUN::VPC::EIP",
      "Properties": {
        "InternetChargeType": "PayByTraffic",
        "InstanceChargeType": "Postpaid"
      }
    },
    "EcsVSwitch": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "VSwitchName": {
          "Fn::Join": [
            "_",
            [
              "StackId",
              {
                "Ref": "ALIYUN::StackId"
              }
            ]
          ]
        },
        "VpcId": {
          "Ref": "EcsVpc"
        },
        "CidrBlock": "192.168.0.0/24",
        "ZoneId": {
          "Ref": "VSwitchZoneId"
        }
      }
    },
    "EcsEniAttachment": {
      "Type": "ALIYUN::ECS::NetworkInterfaceAttachment",
      "Properties": {
        "InstanceId": {
          "Ref": "EcsInstance"
        },
        "NetworkInterfaceId": {
          "Ref": "EcsENI"
        }
      },
      "DependsOn": [
        "EcsInstance",
        "EipAssociation"
      ]
    },
    "EcsInstance": {
      "Type": "ALIYUN::ECS::Instance",
      "Properties": {
        "SystemDiskCategory": {
          "Ref": "EcsSystemDiskCategory"
        },
        "VpcId": {
          "Ref": "EcsVpc"
        },
        "SecurityGroupId": {
          "Ref": "EcsSecurityGroup"
        },
        "SystemDiskSize": {
          "Ref": "EcsSystemDiskSize"
        },
        "ImageId": {
          "Ref": "EcsImageId"
        },
        "AllocatePublicIP": false,
        "InstanceChargeType": "PostPaid",
        "VSwitchId": {
          "Ref": "EcsVSwitch"
        },
        "IoOptimized": "optimized",
        "Password": {
          "Ref": "EcsPassword"
        },
        "InstanceType": {
          "Ref": "EcsInstanceType"
        }
      }
    },
    "EcsVpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "VpcName": {
          "Fn::Join": [
            "-",
            [
              "StackId",
              {
                "Ref": "ALIYUN::StackId"
              }
            ]
          ]
        },
        "CidrBlock": "192.168.0.0/16"
      }
    },
    "EipAssociation": {
      "Type": "ALIYUN::VPC::EIPAssociation",
      "Properties": {
        "InstanceId": {
          "Ref": "EcsENI"
        },
        "AllocationId": {
          "Ref": "Eip"
        },
        "Mode": "NAT"
      },
      "DependsOn": [
        "EcsAssignPrivateIpAddresses",
        "Eip"
      ]
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "VSwitchZoneId",
            "IpAddressCount"
          ],
          "Label": {
            "default": {
              "zh-cn": "專用網路",
              "en": "VPC"
            }
          }
        },
        {
          "Parameters": [
            "EcsInstanceType",
            "EcsImageId",
            "EcsSystemDiskCategory",
            "EcsSystemDiskSize",
            "EcsPassword"
          ],
          "Label": {
            "default": {
              "zh-cn": "雲端服務器",
              "en": "ECS"
            }
          }
        }
      ]
    }
  }
}

情境 3 :建立ECS和彈性IP並掛載多個資料盤。

快速建立

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 建立ECS執行個體,配置彈性IP,掛載2個資料盤,設定網路環境與安全性群組規則。
  en: Create an ECS instance, configure elastic IP, mount 2 data disks, and set network environment and security group rules.
Parameters:
  FirstDataDiskCategory:
    AssociationProperty: ALIYUN::ECS::Disk::DataDiskCategory
    AssociationPropertyMetadata:
      InstanceType: ${InstanceType}
      ZoneId: ${ZoneId}
    Type: String
    Label:
      zh-cn: 資料盤1的磁碟類別
      en: First Data Disk Category
  SystemDiskCategory:
    AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
    AssociationPropertyMetadata:
      InstanceType: InstanceType
      ZoneId: ZoneId
    Type: String
    Label:
      zh-cn: 系統硬碟類型
      en: System Disk Type
  SecondDataDiskSize:
    Default: 40
    Type: Number
    Description:
      zh-cn: 第二個資料盤的大小,單位為GB。值範圍:cloud:[5,2000]、cloud_efficiency:[20,32768]、cloud_ssd:[20,32768]、ephemeral_ssd:[5,800]。該值應等於或大於特定快照。
      en: 'The size of the Second volume, unit in GB.Value range: cloud: [5,2000], cloud_efficiency: [20,32768], cloud_ssd: [20,32768], ephemeral_ssd: [5,800].The value should be equal to or greater than the specific snapshot.'
    Label:
      zh-cn: 資料盤2的磁碟大小
      en: Second Data Disk Size
  SystemDiskSize:
    Default: 40
    Type: Number
    Description:
      zh-cn: 系統硬碟的大小,單位為GB。值範圍:cloud:[5,2000]、cloud_efficiency:[20,32768]、cloud_ssd:[20,32768]、ephemeral_ssd:[5,800]。該值應等於或大於特定快照。
      en: 'Disk size of the system disk, unit in GB.Value range: cloud: [5,2000], cloud_efficiency: [20,32768], cloud_ssd: [20,32768], ephemeral_ssd: [5,800].The value should be equal to or greater than the specific snapshot.'
    Label:
      zh-cn: 系統硬碟大小
      en: System Disk Space
  VpcCidrBlock:
    Default: 192.168.0.0/16
    Label:
      zh-cn: 專用網路網段
      en: VPC CIDR Block
    Type: String
    Description:
      zh-cn: 建立專用網路IP位址區段範圍,推薦使用以下的IP位址區段<br><font color='green'>[10.0.0.0/8]</font><br><font color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0.0/16]</font>
      en: New proprietary network IP address segment range, recommended use of the following IP address segments<br><font color='green'>[10.0.0.0/8]</font><br><font color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0.0/16]</font>
    AllowedValues:
      - 192.168.0.0/16
      - 172.16.0.0/12
      - 10.0.0.0/8
  FirstDataDiskSize:
    Default: 40
    Type: Number
    Description:
      zh-cn: 第一個資料盤的大小,單位為GB。值範圍:cloud:[5,2000]、cloud_efficiency:[20,32768]、cloud_ssd:[20,32768]、ephemeral_ssd:[5,800]。該值應等於或大於特定快照。
      en: 'The size of the first volume, unit in GB.Value range: cloud: [5,2000], cloud_efficiency: [20,32768], cloud_ssd: [20,32768], ephemeral_ssd: [5,800].The value should be equal to or greater than the specific snapshot.'
    Label:
      zh-cn: 資料盤1的磁碟容量
      en: First Data Disk Size
  SecondDataDiskCategory:
    AssociationProperty: ALIYUN::ECS::Disk::DataDiskCategory
    AssociationPropertyMetadata:
      InstanceType: ${InstanceType}
      ZoneId: ${ZoneId}
    Type: String
    Label:
      zh-cn: 資料盤2的磁碟類別
      en: Second Data Disk Category
  VSwitchCidrBlock:
    Default: 192.168.0.0/24
    Type: String
    Description:
      zh-cn: 建立交換器的網段,所屬Virtual Private Cloud絡的子網
      en: Network segments of new switches, subnets of virtual proprietary networks
    Label:
      zh-cn: 交換器網段
      en: VSwitch CIDR Block
  Password:
    ConstraintDescription:
      zh-cn: 長度8-30,必須包含大寫字母、小寫字母、數字、特殊符號三種;特殊字元包括:()`~!@#$%^&*_-+=|{}[]:;' <>,.?/
      en: 'Length 8-30, must contain upper case letters, lower case letters, Numbers, special symbols three; special characters include: ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/'
    Description:
      zh-cn: 伺服器登入密碼,長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)。
      en: Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).
    MinLength: 8
    Label:
      zh-cn: 執行個體密碼
      en: Instance Password
    AllowedPattern: '[a-zA-Z0-9-\(\)\`\~\!@\#\$%\^&\*-+=\|\{\}\[\]\:\;\‘\,\.\?\/]*'
    NoEcho: true
    MaxLength: 30
    Type: String
  InstanceType:
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      ZoneId: ZoneId
    Type: String
    Description:
      zh-cn: <font color='blue'><b>1.選擇機型前請先確認當前可用性區域下該機型是否有貨,部分機型需要提前報備</b></font><br><font color='blue'><b>2.可選機型列表</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB 內網頻寬1Gbps 內網收發包30萬PPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB 內網頻寬1.5Gbps 內網收發包50萬PPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB 內網頻寬2.5Gbps 內網收發包80萬PPS</font>]
      en: <font color='blue'><b>1.Before selecting the model please confirm that the current available zone under the model is in stock, some models need to be reported in advance</b></font><br><font color='blue'><b>2.List of optional models</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB Intranet bandwidth1Gbps In-grid sending and receiving packages30MillionPPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB Intranet bandwidth1.5Gbps In-grid sending and receiving packages50MillionPPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB Intranet bandwidth2.5Gbps In-grid sending and receiving packages80MillionPPS</font>]
    Label:
      zh-cn: 執行個體規格
      en: Instance Type
  ZoneId:
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
    Type: String
    Description:
      zh-cn: 可用性區域ID。<br><b>註: <font color='blue'>選擇前請確認該可用性區域是否支援建立ECS資源的規格,建議與其他交換器可用性區域不同</font></b>
      en: Availability Zone ID.<br><b>note:<font color='blue'>before selecting, please confirm that the Availability Zone supports the specification of creating ECS resources,which is recommended to be different from other VSwitch Availability Zone</font></b>
    Label:
      zh-cn: 交換器可用性區域
      en: VSwitch Availability Zone
  ImageId:
    AssociationPropertyMetadata:
      InstanceType: ${InstanceType}
      SupportedImageOwnerAlias:
        - system
        - self
        - others
    Description:
      zh-cn: 鏡像ID, 詳見:<b><a href='https://www.alibabacloud.com/help/document_detail/112977.html' target='_blank'><font color='blue'>尋找鏡像</font></a></b>
      en: Image ID,See detail:<b><a href='https://www.alibabacloud.com/help/doc-detail/112977.html' target='_blank'><font color='blue'>Find the mirror</font></a></b>
    Default: centos_7_04_64_20G_alibase_201701015.vhd
    Label:
      zh-cn: 鏡像ID
      en: Image ID
    AssociationProperty: ALIYUN::ECS::Image::ImageId
    Type: String
Outputs:
  VpcId:
    Description: Id of created VPC.
    Value:
      Fn::GetAtt:
        - Vpc
        - VpcId
  InstanceId:
    Description: The instance id of created ecs instance.
    Value:
      Fn::GetAtt:
        - WebServer
        - InstanceId
  SecurityGroupId:
    Description: generated security group id for security group.
    Value:
      Fn::GetAtt:
        - SecurityGroup
        - SecurityGroupId
  EipId:
    Description: ID that Aliyun assigns to represent the allocation of the address for use with VPC. Returned only for VPC elastic IP addresses.
    Value:
      Fn::GetAtt:
        - Eip
        - AllocationId
  ZoneId:
    Description: Zone ID of created instance.
    Value:
      Fn::GetAtt:
        - WebServer
        - ZoneId
  VSwitchId:
    Description: Id of created VSwitch.
    Value:
      Fn::GetAtt:
        - VSwitch
        - VSwitchId
Resources:
  EIPBind:
    Type: ALIYUN::VPC::EIPAssociation
    Properties:
      InstanceId:
        Ref: WebServer
      AllocationId:
        Ref: Eip
    Metadata:
      ALIYUN::ROS::Designer:
        id: ece3b051-66c9-46d6-9961-f184d342b21f
  Eip:
    Type: ALIYUN::VPC::EIP
    Properties:
      InternetChargeType: PayByTraffic
      Bandwidth: 1
    Metadata:
      ALIYUN::ROS::Designer:
        id: a914d36e-d429-46d6-bbd0-a22acd07b096
  SecurityGroupEgress:
    Type: ALIYUN::ECS::SecurityGroupEgress
    Properties:
      DestCidrIp: 0.0.0.0/0
      IpProtocol: all
      SecurityGroupId:
        Ref: SecurityGroup
      NicType: intranet
      PortRange: '-1/-1'
    Metadata:
      ALIYUN::ROS::Designer:
        id: faa26b3c-3507-41e9-9959-5db9a9e67446
  SecurityGroup:
    Type: ALIYUN::ECS::SecurityGroup
    Properties:
      VpcId:
        Ref: Vpc
    Metadata:
      ALIYUN::ROS::Designer:
        id: fde92bb4-877d-4e7b-b9dd-be6f5e552544
  SecurityGroupIngress:
    Type: ALIYUN::ECS::SecurityGroupIngress
    Properties:
      IpProtocol: all
      SecurityGroupId:
        Ref: SecurityGroup
      NicType: intranet
      SourceCidrIp: 0.0.0.0/0
      PortRange: '-1/-1'
    Metadata:
      ALIYUN::ROS::Designer:
        id: 2a6cfdef-e236-4966-a976-dd7e7bbc37a5
  WebServer:
    Type: ALIYUN::ECS::Instance
    Properties:
      UserData:
        Fn::Join:
          - ''
          - - |
              #!/bin/sh
            - |
              logs=~/mount_logs
            - |
              i=1
            - |
              total=2
            - |
              while [ $i -le $total ]
            - |
              do
            - |2
                  disk_suffix=`echo $i|awk '{printf "%c", 97+$i}'`
            - |
              fdisk -S 56 /dev/vd$disk_suffix <<ESXU
            - |
              n
            - |
              p
            - |
              1
            - |+

            - |+

            - |
              w
            - |
              ESXU
            - |2
                  echo "/dev/vd$disk_suffix is fdisked!" >> $logs
            - |2
                  mkfs.ext4 /dev/vd${disk_suffix}1
            - |2
                  if [ $? -eq 0 ];then
            - |2
                      echo "/dev/vd${disk_suffix}1 is formated!" >> $logs
            - |2
                  fi
            - |2
                  touch ~/test_ftab
            - |2
                  mkdir $disk_suffix$i
            - |2
                  disk_uuid=`blkid | grep /dev/vd${disk_suffix}1 |awk '{printf $2}'|sed 's/\"//g'`
            - |
              cat << ESXU > ~/test_ftab
            - |
              $disk_uuid         $disk_suffix$i       ext4       defaults        0 0
            - |
              ESXU
            - |2
                  cat ~/test_ftab >> /etc/fstab
            - |2
                  mount -a
            - |2
                  chmod -R 777 $disk_suffix$i
            - |2
                  rm -rf ~/test_ftab
            - |2
                  echo "/dev/vd${disk_suffix}1 is mounted!" >> $logs
            - |2
                  let i+=1
            - |
              done
      SystemDiskCategory:
        Ref: SystemDiskCategory
      VpcId:
        Ref: Vpc
      SecurityGroupId:
        Ref: SecurityGroup
      SystemDiskSize:
        Ref: SystemDiskSize
      ImageId:
        Ref: ImageId
      AllocatePublicIP: 'false'
      VSwitchId:
        Ref: VSwitch
      IoOptimized: optimized
      Password:
        Ref: Password
      DiskMappings:
        - Category:
            Ref: FirstDataDiskCategory
          Size:
            Ref: FirstDataDiskSize
        - Category:
            Ref: SecondDataDiskCategory
          Size:
            Ref: SecondDataDiskSize
      InstanceType:
        Ref: InstanceType
    Metadata:
      ALIYUN::ROS::Designer:
        id: 4f476130-0cde-4cff-a973-2cb026e18f13
  Vpc:
    Type: ALIYUN::ECS::VPC
    Properties:
      CidrBlock:
        Ref: VpcCidrBlock
    Metadata:
      ALIYUN::ROS::Designer:
        id: adfdd097-9c30-49ff-8738-ae3b59eada43
  VSwitch:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      VpcId:
        Fn::GetAtt:
          - Vpc
          - VpcId
      CidrBlock:
        Ref: VSwitchCidrBlock
      ZoneId:
        Ref: ZoneId
    Metadata:
      ALIYUN::ROS::Designer:
        id: bd814869-3bd7-4551-a5db-0ec7ad3d3246
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - ZoneId
          - VpcCidrBlock
          - VSwitchCidrBlock
        Label:
          default:
            zh-cn: 基礎資源配置(必填)
            en: Infrastructure Configuration
      - Parameters:
          - InstanceType
          - ImageId
          - Password
        Label:
          default:
            zh-cn: ECS 配置(必填)
            en: ECS Configuration
      - Parameters:
          - SystemDiskSize
          - SystemDiskCategory
          - FirstDataDiskSize
          - FirstDataDiskCategory
          - SecondDataDiskSize
          - SecondDataDiskCategory
        Label:
          default:
            zh-cn: ECS 磁碟配置(必填)
            en: ECS Disk Configuration
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "建立ECS執行個體,配置彈性IP,掛載2個資料盤,設定網路環境與安全性群組規則。",
    "en": "Create an ECS instance, configure elastic IP, mount 2 data disks, and set network environment and security group rules."
  },
  "Parameters": {
    "FirstDataDiskCategory": {
      "AssociationProperty": "ALIYUN::ECS::Disk::DataDiskCategory",
      "AssociationPropertyMetadata": {
        "InstanceType": "${InstanceType}",
        "ZoneId": "${ZoneId}"
      },
      "Type": "String",
      "Label": {
        "zh-cn": "資料盤1的磁碟類別",
        "en": "First Data Disk Category"
      }
    },
    "SystemDiskCategory": {
      "AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
      "AssociationPropertyMetadata": {
        "InstanceType": "InstanceType",
        "ZoneId": "ZoneId"
      },
      "Type": "String",
      "Label": {
        "zh-cn": "系統硬碟類型",
        "en": "System Disk Type"
      }
    },
    "SecondDataDiskSize": {
      "Default": 40,
      "Type": "Number",
      "Description": {
        "zh-cn": "第二個資料盤的大小,單位為GB。值範圍:cloud:[5,2000]、cloud_efficiency:[20,32768]、cloud_ssd:[20,32768]、ephemeral_ssd:[5,800]。該值應等於或大於特定快照。",
        "en": "The size of the Second volume, unit in GB.Value range: cloud: [5,2000], cloud_efficiency: [20,32768], cloud_ssd: [20,32768], ephemeral_ssd: [5,800].The value should be equal to or greater than the specific snapshot."
      },
      "Label": {
        "zh-cn": "資料盤2的磁碟大小",
        "en": "Second Data Disk Size"
      }
    },
    "SystemDiskSize": {
      "Default": 40,
      "Type": "Number",
      "Description": {
        "zh-cn": "系統硬碟的大小,單位為GB。值範圍:cloud:[5,2000]、cloud_efficiency:[20,32768]、cloud_ssd:[20,32768]、ephemeral_ssd:[5,800]。該值應等於或大於特定快照。",
        "en": "Disk size of the system disk, unit in GB.Value range: cloud: [5,2000], cloud_efficiency: [20,32768], cloud_ssd: [20,32768], ephemeral_ssd: [5,800].The value should be equal to or greater than the specific snapshot."
      },
      "Label": {
        "zh-cn": "系統硬碟大小",
        "en": "System Disk Space"
      }
    },
    "VpcCidrBlock": {
      "Default": "192.168.0.0/16",
      "Label": {
        "zh-cn": "專用網路網段",
        "en": "VPC CIDR Block"
      },
      "Type": "String",
      "Description": {
        "zh-cn": "建立專用網路IP位址區段範圍,推薦使用以下的IP位址區段<br><font color='green'>[10.0.0.0/8]</font><br><font color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0.0/16]</font>",
        "en": "New proprietary network IP address segment range, recommended use of the following IP address segments<br><font color='green'>[10.0.0.0/8]</font><br><font color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0.0/16]</font>"
      },
      "AllowedValues": [
        "192.168.0.0/16",
        "172.16.0.0/12",
        "10.0.0.0/8"
      ]
    },
    "FirstDataDiskSize": {
      "Default": 40,
      "Type": "Number",
      "Description": {
        "zh-cn": "第一個資料盤的大小,單位為GB。值範圍:cloud:[5,2000]、cloud_efficiency:[20,32768]、cloud_ssd:[20,32768]、ephemeral_ssd:[5,800]。該值應等於或大於特定快照。",
        "en": "The size of the first volume, unit in GB.Value range: cloud: [5,2000], cloud_efficiency: [20,32768], cloud_ssd: [20,32768], ephemeral_ssd: [5,800].The value should be equal to or greater than the specific snapshot."
      },
      "Label": {
        "zh-cn": "資料盤1的磁碟容量",
        "en": "First Data Disk Size"
      }
    },
    "SecondDataDiskCategory": {
      "AssociationProperty": "ALIYUN::ECS::Disk::DataDiskCategory",
      "AssociationPropertyMetadata": {
        "InstanceType": "${InstanceType}",
        "ZoneId": "${ZoneId}"
      },
      "Type": "String",
      "Label": {
        "zh-cn": "資料盤2的磁碟類別",
        "en": "Second Data Disk Category"
      }
    },
    "VSwitchCidrBlock": {
      "Default": "192.168.0.0/24",
      "Type": "String",
      "Description": {
        "zh-cn": "建立交換器的網段,所屬Virtual Private Cloud絡的子網",
        "en": "Network segments of new switches, subnets of virtual proprietary networks"
      },
      "Label": {
        "zh-cn": "交換器網段",
        "en": "VSwitch CIDR Block"
      }
    },
    "Password": {
      "ConstraintDescription": {
        "zh-cn": "長度8-30,必須包含大寫字母、小寫字母、數字、特殊符號三種;特殊字元包括:()`~!@#$%^&*_-+=|{}[]:;' <>,.?/",
        "en": "Length 8-30, must contain upper case letters, lower case letters, Numbers, special symbols three; special characters include: ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
      },
      "Description": {
        "zh-cn": "伺服器登入密碼,長度8-30,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)。",
        "en": "Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)."
      },
      "MinLength": 8,
      "Label": {
        "zh-cn": "執行個體密碼",
        "en": "Instance Password"
      },
      "AllowedPattern": "[a-zA-Z0-9-\\(\\)\\`\\~\\!@\\#\\$%\\^&\\*-+=\\|\\{\\}\\[\\]\\:\\;\\‘\\,\\.\\?\\/]*",
      "NoEcho": true,
      "MaxLength": 30,
      "Type": "String"
    },
    "InstanceType": {
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "ZoneId": "ZoneId"
      },
      "Type": "String",
      "Description": {
        "zh-cn": "<font color='blue'><b>1.選擇機型前請先確認當前可用性區域下該機型是否有貨,部分機型需要提前報備</b></font><br><font color='blue'><b>2.可選機型列表</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB 內網頻寬1Gbps 內網收發包30萬PPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB 內網頻寬1.5Gbps 內網收發包50萬PPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB 內網頻寬2.5Gbps 內網收發包80萬PPS</font>]",
        "en": "<font color='blue'><b>1.Before selecting the model please confirm that the current available zone under the model is in stock, some models need to be reported in advance</b></font><br><font color='blue'><b>2.List of optional models</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB Intranet bandwidth1Gbps In-grid sending and receiving packages30MillionPPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB Intranet bandwidth1.5Gbps In-grid sending and receiving packages50MillionPPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB Intranet bandwidth2.5Gbps In-grid sending and receiving packages80MillionPPS</font>]"
      },
      "Label": {
        "zh-cn": "執行個體規格",
        "en": "Instance Type"
      }
    },
    "ZoneId": {
      "AssociationProperty": "ALIYUN::ECS::Instance:ZoneId",
      "Type": "String",
      "Description": {
        "zh-cn": "可用性區域ID。<br><b>註: <font color='blue'>選擇前請確認該可用性區域是否支援建立ECS資源的規格,建議與其他交換器可用性區域不同</font></b>",
        "en": "Availability Zone ID.<br><b>note:<font color='blue'>before selecting, please confirm that the Availability Zone supports the specification of creating ECS resources,which is recommended to be different from other VSwitch Availability Zone</font></b>"
      },
      "Label": {
        "zh-cn": "交換器可用性區域",
        "en": "VSwitch Availability Zone"
      }
    },
    "ImageId": {
      "AssociationPropertyMetadata": {
        "InstanceType": "${InstanceType}",
        "SupportedImageOwnerAlias": [
          "system",
          "self",
          "others"
        ]
      },
      "Description": {
        "zh-cn": "鏡像ID, 詳見:<b><a href='https://www.alibabacloud.com/help/document_detail/112977.html' target='_blank'><font color='blue'>尋找鏡像</font></a></b>",
        "en": "Image ID,See detail:<b><a href='https://www.alibabacloud.com/help/doc-detail/112977.html' target='_blank'><font color='blue'>Find the mirror</font></a></b>"
      },
      "Default": "centos_7_04_64_20G_alibase_201701015.vhd",
      "Label": {
        "zh-cn": "鏡像ID",
        "en": "Image ID"
      },
      "AssociationProperty": "ALIYUN::ECS::Image::ImageId",
      "Type": "String"
    }
  },
  "Outputs": {
    "VpcId": {
      "Description": "Id of created VPC.",
      "Value": {
        "Fn::GetAtt": [
          "Vpc",
          "VpcId"
        ]
      }
    },
    "InstanceId": {
      "Description": "The instance id of created ecs instance.",
      "Value": {
        "Fn::GetAtt": [
          "WebServer",
          "InstanceId"
        ]
      }
    },
    "SecurityGroupId": {
      "Description": "generated security group id for security group.",
      "Value": {
        "Fn::GetAtt": [
          "SecurityGroup",
          "SecurityGroupId"
        ]
      }
    },
    "EipId": {
      "Description": "ID that Aliyun assigns to represent the allocation of the address for use with VPC. Returned only for VPC elastic IP addresses.",
      "Value": {
        "Fn::GetAtt": [
          "Eip",
          "AllocationId"
        ]
      }
    },
    "ZoneId": {
      "Description": "Zone ID of created instance.",
      "Value": {
        "Fn::GetAtt": [
          "WebServer",
          "ZoneId"
        ]
      }
    },
    "VSwitchId": {
      "Description": "Id of created VSwitch.",
      "Value": {
        "Fn::GetAtt": [
          "VSwitch",
          "VSwitchId"
        ]
      }
    }
  },
  "Resources": {
    "EIPBind": {
      "Type": "ALIYUN::VPC::EIPAssociation",
      "Properties": {
        "InstanceId": {
          "Ref": "WebServer"
        },
        "AllocationId": {
          "Ref": "Eip"
        }
      },
      "Metadata": {
        "ALIYUN::ROS::Designer": {
          "id": "ece3b051-66c9-46d6-9961-f184d342b21f"
        }
      }
    },
    "Eip": {
      "Type": "ALIYUN::VPC::EIP",
      "Properties": {
        "InternetChargeType": "PayByTraffic",
        "Bandwidth": 1
      },
      "Metadata": {
        "ALIYUN::ROS::Designer": {
          "id": "a914d36e-d429-46d6-bbd0-a22acd07b096"
        }
      }
    },
    "SecurityGroupEgress": {
      "Type": "ALIYUN::ECS::SecurityGroupEgress",
      "Properties": {
        "DestCidrIp": "0.0.0.0/0",
        "IpProtocol": "all",
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "NicType": "intranet",
        "PortRange": "-1/-1"
      },
      "Metadata": {
        "ALIYUN::ROS::Designer": {
          "id": "faa26b3c-3507-41e9-9959-5db9a9e67446"
        }
      }
    },
    "SecurityGroup": {
      "Type": "ALIYUN::ECS::SecurityGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        }
      },
      "Metadata": {
        "ALIYUN::ROS::Designer": {
          "id": "fde92bb4-877d-4e7b-b9dd-be6f5e552544"
        }
      }
    },
    "SecurityGroupIngress": {
      "Type": "ALIYUN::ECS::SecurityGroupIngress",
      "Properties": {
        "IpProtocol": "all",
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "NicType": "intranet",
        "SourceCidrIp": "0.0.0.0/0",
        "PortRange": "-1/-1"
      },
      "Metadata": {
        "ALIYUN::ROS::Designer": {
          "id": "2a6cfdef-e236-4966-a976-dd7e7bbc37a5"
        }
      }
    },
    "WebServer": {
      "Type": "ALIYUN::ECS::Instance",
      "Properties": {
        "UserData": {
          "Fn::Join": [
            "",
            [
              "#!/bin/sh\n",
              "logs=~/mount_logs\n",
              "i=1\n",
              "total=2\n",
              "while [ $i -le $total ]\n",
              "do\n",
              "    disk_suffix=`echo $i|awk '{printf \"%c\", 97+$i}'`\n",
              "fdisk -S 56 /dev/vd$disk_suffix <<ESXU\n",
              "n\n",
              "p\n",
              "1\n",
              "\n",
              "\n",
              "w\n",
              "ESXU\n",
              "    echo \"/dev/vd$disk_suffix is fdisked!\" >> $logs\n",
              "    mkfs.ext4 /dev/vd${disk_suffix}1\n",
              "    if [ $? -eq 0 ];then\n",
              "        echo \"/dev/vd${disk_suffix}1 is formated!\" >> $logs\n",
              "    fi\n",
              "    touch ~/test_ftab\n",
              "    mkdir $disk_suffix$i\n",
              "    disk_uuid=`blkid | grep /dev/vd${disk_suffix}1 |awk '{printf $2}'|sed 's/\\\"//g'`\n",
              "cat << ESXU > ~/test_ftab\n",
              "$disk_uuid         $disk_suffix$i       ext4       defaults        0 0\n",
              "ESXU\n",
              "    cat ~/test_ftab >> /etc/fstab\n",
              "    mount -a\n",
              "    chmod -R 777 $disk_suffix$i\n",
              "    rm -rf ~/test_ftab\n",
              "    echo \"/dev/vd${disk_suffix}1 is mounted!\" >> $logs\n",
              "    let i+=1\n",
              "done\n"
            ]
          ]
        },
        "SystemDiskCategory": {
          "Ref": "SystemDiskCategory"
        },
        "VpcId": {
          "Ref": "Vpc"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "SystemDiskSize": {
          "Ref": "SystemDiskSize"
        },
        "ImageId": {
          "Ref": "ImageId"
        },
        "AllocatePublicIP": "false",
        "VSwitchId": {
          "Ref": "VSwitch"
        },
        "IoOptimized": "optimized",
        "Password": {
          "Ref": "Password"
        },
        "DiskMappings": [
          {
            "Category": {
              "Ref": "FirstDataDiskCategory"
            },
            "Size": {
              "Ref": "FirstDataDiskSize"
            }
          },
          {
            "Category": {
              "Ref": "SecondDataDiskCategory"
            },
            "Size": {
              "Ref": "SecondDataDiskSize"
            }
          }
        ],
        "InstanceType": {
          "Ref": "InstanceType"
        }
      },
      "Metadata": {
        "ALIYUN::ROS::Designer": {
          "id": "4f476130-0cde-4cff-a973-2cb026e18f13"
        }
      }
    },
    "Vpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "CidrBlock": {
          "Ref": "VpcCidrBlock"
        }
      },
      "Metadata": {
        "ALIYUN::ROS::Designer": {
          "id": "adfdd097-9c30-49ff-8738-ae3b59eada43"
        }
      }
    },
    "VSwitch": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "VpcId": {
          "Fn::GetAtt": [
            "Vpc",
            "VpcId"
          ]
        },
        "CidrBlock": {
          "Ref": "VSwitchCidrBlock"
        },
        "ZoneId": {
          "Ref": "ZoneId"
        }
      },
      "Metadata": {
        "ALIYUN::ROS::Designer": {
          "id": "bd814869-3bd7-4551-a5db-0ec7ad3d3246"
        }
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "ZoneId",
            "VpcCidrBlock",
            "VSwitchCidrBlock"
          ],
          "Label": {
            "default": {
              "zh-cn": "基礎資源配置(必填)",
              "en": "Infrastructure Configuration"
            }
          }
        },
        {
          "Parameters": [
            "InstanceType",
            "ImageId",
            "Password"
          ],
          "Label": {
            "default": {
              "zh-cn": "ECS 配置(必填)",
              "en": "ECS Configuration"
            }
          }
        },
        {
          "Parameters": [
            "SystemDiskSize",
            "SystemDiskCategory",
            "FirstDataDiskSize",
            "FirstDataDiskCategory",
            "SecondDataDiskSize",
            "SecondDataDiskCategory"
          ],
          "Label": {
            "default": {
              "zh-cn": "ECS 磁碟配置(必填)",
              "en": "ECS Disk Configuration"
            }
          }
        }
      ]
    }
  }
}

更多樣本,請參考包含此資源的公用模板。