全部产品
Search
文档中心

资源编排:ALIYUN::ECS::Instance

更新时间:Feb 05, 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实例创建指定专有宿主机上。

您可以通过调用DescribeDedicatedHosts接口查询专有宿主机ID列表

。由于专有宿主机不支持创建抢占式实例,指定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

是否在专有宿主机上创建实例。

取值:

  • default(默认值):创建非专有宿主机实例。

  • host:创建专有宿主机实例。若您不指定DedicatedHostId,则由阿里云自动选择专有宿主机放置实例。

StorageSetPartitionNumber

Integer

存储集中的最大分区数量。

取值范围:大于等于2。

DeploymentSetGroupNo

Integer

如果您设置的部署集对应的策略为部署集组高可用策略(AvailabilityGroup),可以通过该参数指定实例在部署集中的分组号。

取值范围:1~7。

Affinity

String

专有宿主机实例是否与专有宿主机关联。

取值:

  • default(默认值):实例不与专有宿主机关联。已启用节省停机模式的实例,停机后再次启动时,若原专有宿主机可用资源不足,则实例被放置在自动部署资源池的其他专有宿主机上。

  • 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实例。

  • 在专有宿主机DDH上创建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: 专有网络VPC实例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": "专有网络VPC实例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: 新建交换机的网段,所属虚拟专有网络的子网
      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": "新建交换机的网段,所属虚拟专有网络的子网",
        "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"
            }
          }
        }
      ]
    }
  }
}

更多示例,请参考包含此资源的公共模板。