ALIYUN::ECS::Instance类型用于创建ECS实例。

语法

{
  "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,
    "UserData": String,
    "SystemDiskSize": Number,
    "ZoneId": String,
    "InternetMaxBandwidthOut": Integer,
    "VpcId": String,
    "SpotStrategy": String,
    "InstanceName": String,
    "InternetMaxBandwidthIn": Integer,
    "DeletionProtection": Boolean,
    "DeploymentSetId": String,
    "SecurityGroupId": String,
    "SecurityEnhancementStrategy": String,
    "SpotPriceLimit": String,
    "HpcClusterId": String,
    "AllocatePublicIP": Boolean,
    "SystemDiskDescription": String,
    "SystemDiskPerformanceLevel": String,
    "DiskMappings": List
  }
}

属性

属性名称 类型 必须 允许更新 描述 约束
ResourceGroupId String 资源组ID。
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(默认值):按流量计费)。
InternetMaxBandwidthIn Integer 公网入带宽最大值。 取值范围:1~200。

默认值:200。

单位:Mbps。

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云盘作为系统盘使用时,设置云盘的性能等级。 取值:
  • PL1(默认值):单盘最高随机读写IOPS为5万。
  • PL2:单盘最高随机读写IOPS为10万。
  • PL3:单盘最高随机读写IOPS为100万。
关于如何选择ESSD性能等级,请参见ESSD云盘

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://

返回值

Fn::GetAtt

  • InstanceId:实例ID。由系统生成,实例的全局唯一标识。
  • PrivateIp:VPC类型实例的私网IP地址。
  • InnerIp:Classic类型实例的内网IP地址。
  • PublicIp:Classic类型实例的公网IP地址。
  • ZoneId:可用区ID。
  • HostName:云服务器的主机名。
  • PrimaryNetworkInterfaceId:主网卡ID。
  • SecurityGroupIds:已创建实例的安全组ID列表。

示例

JSON格式

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "DedicatedHostId": {
      "Type": "String",
      "Description": "which dedicated host will be deployed"
    },
    "PrivateIpAddress": {
      "Type": "String",
      "Description": "Private IP for the instance created. Only works for VPC instance and cannot duplicated with existing instance."
    },
    "Description": {
      "Type": "String",
      "Description": "Description of the instance, [2, 256] characters. Do not fill or empty, the default is empty."
    },
    "ResourceGroupId": {
      "Type": "String",
      "Description": "Resource group id."
    },
    "DiskMappings": {
      "Type": "Json",
      "Description": "Disk mappings to attach to instance. Max support 16 disks.\nIf the image contains a data disk, you can specify other parameters of the data disk via the same value of parameter \"Device\". If parameter \"Category\" is not specified, it will be cloud_efficiency instead of \"Category\" of data disk in the image.",
      "MaxLength": 16
    },
    "UserData": {
      "Type": "String",
      "Description": "User data to pass to instance. [1, 16KB] characters.User data should not be base64 encoded. If you want to pass base64 encoded string to the property, use function Fn::Base64Decode to decode the base64 string first."
    },
    "SystemDiskSize": {
      "Type": "Number",
      "Description": "Disk size of the system disk, range from 20 to 500 GB. If you specify with your own image, make sure the system disk size bigger than image size. ",
      "MinValue": 20
    },
    "SystemDiskDescription": {
      "Type": "String",
      "Description": "Description of created system disk."
    },
    "InstanceChargeType": {
      "Type": "String",
      "Description": "Instance Charge type, allowed value: Prepaid and Postpaid. If specified Prepaid, please ensure you have sufficient balance in your account. Or instance creation will be failure. Default value is Postpaid.",
      "AllowedValues": [
        "Subscription",
        "PrePaid",
        "PrePay",
        "Prepaid",
        "PayAsYouGo",
        "PostPaid",
        "PayOnDemand",
        "Postpaid"
      ],
      "Default": "PostPaid"
    },
    "AutoRenew": {
      "Type": "String",
      "Description": "Whether renew the fee automatically? When the parameter InstanceChargeType is PrePaid, it will take effect. Range of value:True: automatic renewal.False: no automatic renewal. Default value is False.",
      "AllowedValues": [
        "True",
        "False"
      ],
      "Default": "False"
    },
    "RamRoleName": {
      "Type": "String",
      "Description": "Instance RAM role name. The name is provided and maintained by Resource Access Management (RAM) and can be queried using ListRoles. For more information, see RAM API CreateRole and ListRoles."
    },
    "SystemDiskPerformanceLevel": {
      "Type": "String",
      "Description": "The performance level of the enhanced SSD used as the system disk.Default value: PL1. Valid values:PL0: A single enhanced SSD delivers up to 10,000 random read/write IOPS.PL1: A single enhanced SSD delivers up to 50,000 random read/write IOPS.PL2: A single enhanced SSD delivers up to 100,000 random read/write IOPS.PL3: A single enhanced SSD delivers up to 1,000,000 random read/write IOPS."
    },
    "ImageId": {
      "Type": "String",
      "Description": "Image ID to create ecs instance."
    },
    "SystemDiskDiskName": {
      "Type": "String",
      "Description": "Name of created system disk."
    },
    "SpotPriceLimit": {
      "Type": "String",
      "Description": "The hourly price threshold of a instance, and it takes effect only when parameter InstanceChargeType is PostPaid. Three decimals is allowed at most. "
    },
    "InstanceType": {
      "Type": "String",
      "Description": "Ecs instance supported instance type, make sure it should be correct."
    },
    "AllocatePublicIP": {
      "Type": "Boolean",
      "Description": "The public ip for ecs instance, if properties is true, will allocate public ip. If property InternetMaxBandwidthOut set to 0, it will not assign public ip.",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ],
      "Default": true
    },
    "Tags": {
      "Type": "Json",
      "Description": "Tags to attach to instance. Max support 20 tags to add during create instance. Each tag with two properties Key and Value, and Key is required.",
      "MaxLength": 20
    },
    "HostName": {
      "Type": "String",
      "Description": "Host name of created ecs instance. at least 2 characters, and '.' '-' Is not the first and last characters as hostname, not continuous use. Windows platform can be up to 15 characters, allowing letters (without limiting case), numbers and '-', and does not support the number of points, not all is digital ('.').Other (Linux, etc.) platform up to 30 characters, allowing support number multiple points for the period between the points, each permit letters (without limiting case), numbers and '-' components."
    },
    "SpotStrategy": {
      "Type": "String",
      "Description": "The spot strategy of a Pay-As-You-Go instance, and it takes effect only when parameter InstanceChargeType is PostPaid. Value range: \"NoSpot: A regular Pay-As-You-Go instance\", \"SpotWithPriceLimit: A price threshold for a spot instance, \"\"SpotAsPriceGo: A price that is based on the highest Pay-As-You-Go instance. \"Default value: NoSpot.",
      "AllowedValues": [
        "NoSpot",
        "SpotWithPriceLimit",
        "SpotAsPriceGo"
      ]
    },
    "PasswordInherit": {
      "Type": "Boolean",
      "Description": "Specifies whether to use the password preset in the image. To use the PasswordInherit parameter, the Password parameter must be empty and you must make sure that the selected image has a password configured.",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ]
    },
    "Password": {
      "Type": "String",
      "Description": "Password of created ecs instance. Must contain at least 3 types of special character, lower character, upper character, number."
    },
    "AutoRenewPeriod": {
      "Type": "Number",
      "Description": "The time period of auto renew. When the parameter InstanceChargeType is PrePaid, it will take effect.It could be 1, 2, 3, 6, 12. Default value is 1.",
      "AllowedValues": [
        1,
        2,
        3,
        6,
        12
      ],
      "Default": 1
    },
    "KeyPairName": {
      "Type": "String",
      "Description": "SSH key pair name."
    },
    "IoOptimized": {
      "Type": "String",
      "Description": "The 'optimized' instance can provide better IO performance. Support 'none' and 'optimized' only, default is 'optimized'.",
      "AllowedValues": [
        "none",
        "optimized"
      ],
      "Default": "optimized"
    },
    "ZoneId": {
      "Type": "String",
      "Description": "The ID of the zone to which the instance belongs. For more information, \ncall the DescribeZones operation to query the most recent zone list. \nDefault value is empty, which means random selection."
    },
    "HpcClusterId": {
      "Type": "String",
      "Description": "The HPC cluster ID to which the instance belongs."
    },
    "VSwitchId": {
      "Type": "String",
      "Description": "The vSwitch Id to create ecs instance."
    },
    "SecurityGroupId": {
      "Type": "String",
      "Description": "Security group to create ecs instance. For classic instance need the security group not belong to VPC, for VPC instance, please make sure the security group belong to specified VPC."
    },
    "Period": {
      "Type": "Number",
      "Description": "Prepaid time period. Unit is month, it could be from 1 to 9 or 12, 24, 36, 48, 60. Default value is 1.",
      "AllowedValues": [
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        12,
        24,
        36,
        48,
        60
      ],
      "Default": 1
    },
    "DeletionProtection": {
      "Type": "Boolean",
      "Description": "Whether an instance can be released manually through the console or API, deletion protection only support postPaid instance",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ]
    },
    "SecurityGroupIds": {
      "Type": "Json",
      "Description": "The ID list of security group to which to assign the instance. The max length is based on the maximum number of security groups to which an instance can belong. For more information, see the \"Security group limits\" section in Limits.",
      "MinLength": 1,
      "MaxLength": 16
    },
    "InternetChargeType": {
      "Type": "String",
      "Description": "Instance internet access charge type.Support 'PayByBandwidth' and 'PayByTraffic' only. Default is PayByTraffic",
      "AllowedValues": [
        "paybytraffic",
        "PayByTraffic",
        "paybybandwidth",
        "PayByBandwidth"
      ],
      "Default": "PayByTraffic"
    },
    "SystemDiskCategory": {
      "Type": "String",
      "Description": "Category of system disk. Default is cloud_efficiency. support cloud|cloud_efficiency|cloud_ssd|cloud_essd|ephemeral_ssd",
      "AllowedValues": [
        "cloud",
        "cloud_efficiency",
        "cloud_ssd",
        "cloud_essd",
        "ephemeral_ssd"
      ],
      "Default": "cloud_efficiency"
    },
    "InstanceName": {
      "Type": "String",
      "Description": "Display name of the instance, [2, 128] English or Chinese characters, must start with a letter or Chinese in size, can contain numbers, '_' or '.', '-'"
    },
    "DeploymentSetId": {
      "Type": "String",
      "Description": "Deployment set ID."
    },
    "InternetMaxBandwidthOut": {
      "Type": "Number",
      "Description": "Set internet output bandwidth of instance. Unit is Mbps(Mega bit per second). Range is [0,200]. Default is 1.While the property is not 0, public ip will be assigned for instance.",
      "MinValue": 0,
      "MaxValue": 200,
      "Default": 1
    },
    "VpcId": {
      "Type": "String",
      "Description": "The VPC id to create ecs instance."
    },
    "InternetMaxBandwidthIn": {
      "Type": "Number",
      "Description": "Max internet out band width setting, unit in Mbps(Mega bit per second). The range is [1,200], default is 200 Mbps.",
      "MinValue": 1,
      "MaxValue": 200,
      "Default": 200
    },
    "SecurityEnhancementStrategy": {
      "Type": "String",
      "Description": "",
      "AllowedValues": [
        "Active",
        "Deactive"
      ]
    },
    "PeriodUnit": {
      "Type": "String",
      "Description": "Unit of prepaid time period, it could be Week/Month/Year. Default value is Month.",
      "AllowedValues": [
        "Week",
        "Month",
        "Year"
      ],
      "Default": "Month"
    }
  },
  "Resources": {
    "Instance": {
      "Type": "ALIYUN::ECS::Instance",
      "Properties": {
        "DedicatedHostId": {
          "Ref": "DedicatedHostId"
        },
        "PrivateIpAddress": {
          "Ref": "PrivateIpAddress"
        },
        "Description": {
          "Ref": "Description"
        },
        "ResourceGroupId": {
          "Ref": "ResourceGroupId"
        },
        "DiskMappings": {
          "Ref": "DiskMappings"
        },
        "UserData": {
          "Ref": "UserData"
        },
        "SystemDiskSize": {
          "Ref": "SystemDiskSize"
        },
        "SystemDiskDescription": {
          "Ref": "SystemDiskDescription"
        },
        "InstanceChargeType": {
          "Ref": "InstanceChargeType"
        },
        "AutoRenew": {
          "Ref": "AutoRenew"
        },
        "RamRoleName": {
          "Ref": "RamRoleName"
        },
        "SystemDiskPerformanceLevel": {
          "Ref": "SystemDiskPerformanceLevel"
        },
        "ImageId": {
          "Ref": "ImageId"
        },
        "SystemDiskDiskName": {
          "Ref": "SystemDiskDiskName"
        },
        "SpotPriceLimit": {
          "Ref": "SpotPriceLimit"
        },
        "InstanceType": {
          "Ref": "InstanceType"
        },
        "AllocatePublicIP": {
          "Ref": "AllocatePublicIP"
        },
        "Tags": {
          "Ref": "Tags"
        },
        "HostName": {
          "Ref": "HostName"
        },
        "SpotStrategy": {
          "Ref": "SpotStrategy"
        },
        "PasswordInherit": {
          "Ref": "PasswordInherit"
        },
        "Password": {
          "Ref": "Password"
        },
        "AutoRenewPeriod": {
          "Ref": "AutoRenewPeriod"
        },
        "KeyPairName": {
          "Ref": "KeyPairName"
        },
        "IoOptimized": {
          "Ref": "IoOptimized"
        },
        "ZoneId": {
          "Ref": "ZoneId"
        },
        "HpcClusterId": {
          "Ref": "HpcClusterId"
        },
        "VSwitchId": {
          "Ref": "VSwitchId"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroupId"
        },
        "Period": {
          "Ref": "Period"
        },
        "DeletionProtection": {
          "Ref": "DeletionProtection"
        },
        "SecurityGroupIds": {
          "Ref": "SecurityGroupIds"
        },
        "InternetChargeType": {
          "Ref": "InternetChargeType"
        },
        "SystemDiskCategory": {
          "Ref": "SystemDiskCategory"
        },
        "InstanceName": {
          "Ref": "InstanceName"
        },
        "DeploymentSetId": {
          "Ref": "DeploymentSetId"
        },
        "InternetMaxBandwidthOut": {
          "Ref": "InternetMaxBandwidthOut"
        },
        "VpcId": {
          "Ref": "VpcId"
        },
        "InternetMaxBandwidthIn": {
          "Ref": "InternetMaxBandwidthIn"
        },
        "SecurityEnhancementStrategy": {
          "Ref": "SecurityEnhancementStrategy"
        },
        "PeriodUnit": {
          "Ref": "PeriodUnit"
        }
      }
    }
  },
  "Outputs": {
    "PrimaryNetworkInterfaceId": {
      "Description": "Primary network interface ID of created instance.",
      "Value": {
        "Fn::GetAtt": [
          "Instance",
          "PrimaryNetworkInterfaceId"
        ]
      }
    },
    "InnerIp": {
      "Description": "Inner IP address of the specified instance. Only for classical instance.",
      "Value": {
        "Fn::GetAtt": [
          "Instance",
          "InnerIp"
        ]
      }
    },
    "ZoneId": {
      "Description": "Zone ID of created instance.",
      "Value": {
        "Fn::GetAtt": [
          "Instance",
          "ZoneId"
        ]
      }
    },
    "PrivateIp": {
      "Description": "Private IP address of created ecs instance. Only for VPC instance.",
      "Value": {
        "Fn::GetAtt": [
          "Instance",
          "PrivateIp"
        ]
      }
    },
    "InstanceId": {
      "Description": "The instance ID of created ecs instance",
      "Value": {
        "Fn::GetAtt": [
          "Instance",
          "InstanceId"
        ]
      }
    },
    "PublicIp": {
      "Description": "Public IP address of created ecs instance.",
      "Value": {
        "Fn::GetAtt": [
          "Instance",
          "PublicIp"
        ]
      }
    },
    "SecurityGroupIds": {
      "Description": "Security group ID list of created instance.",
      "Value": {
        "Fn::GetAtt": [
          "Instance",
          "SecurityGroupIds"
        ]
      }
    },
    "HostName": {
      "Description": "Host name of created instance.",
      "Value": {
        "Fn::GetAtt": [
          "Instance",
          "HostName"
        ]
      }
    }
  }
}

YAML格式

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  AllocatePublicIP:
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Default: true
    Description: The public ip for ecs instance, if properties is true, will allocate
      public ip. If property InternetMaxBandwidthOut set to 0, it will not assign
      public ip.
    Type: Boolean
  AutoRenew:
    AllowedValues:
    - 'True'
    - 'False'
    Default: 'False'
    Description: 'Whether renew the fee automatically? When the parameter InstanceChargeType
      is PrePaid, it will take effect. Range of value:True: automatic renewal.False:
      no automatic renewal. Default value is False.'
    Type: String
  AutoRenewPeriod:
    AllowedValues:
    - 1
    - 2
    - 3
    - 6
    - 12
    Default: 1
    Description: The time period of auto renew. When the parameter InstanceChargeType
      is PrePaid, it will take effect.It could be 1, 2, 3, 6, 12. Default value is
      1.
    Type: Number
  DedicatedHostId:
    Description: which dedicated host will be deployed
    Type: String
  DeletionProtection:
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Description: Whether an instance can be released manually through the console
      or API, deletion protection only support postPaid instance
    Type: Boolean
  DeploymentSetId:
    Description: Deployment set ID.
    Type: String
  Description:
    Description: Description of the instance, [2, 256] characters. Do not fill or
      empty, the default is empty.
    Type: String
  DiskMappings:
    Description: 'Disk mappings to attach to instance. Max support 16 disks.

      If the image contains a data disk, you can specify other parameters of the data
      disk via the same value of parameter "Device". If parameter "Category" is not
      specified, it will be cloud_efficiency instead of "Category" of data disk in
      the image.'
    MaxLength: 16
    Type: Json
  HostName:
    Description: Host name of created ecs instance. at least 2 characters, and '.'
      '-' Is not the first and last characters as hostname, not continuous use. Windows
      platform can be up to 15 characters, allowing letters (without limiting case),
      numbers and '-', and does not support the number of points, not all is digital
      ('.').Other (Linux, etc.) platform up to 30 characters, allowing support number
      multiple points for the period between the points, each permit letters (without
      limiting case), numbers and '-' components.
    Type: String
  HpcClusterId:
    Description: The HPC cluster ID to which the instance belongs.
    Type: String
  ImageId:
    Description: Image ID to create ecs instance.
    Type: String
  InstanceChargeType:
    AllowedValues:
    - Subscription
    - PrePaid
    - PrePay
    - Prepaid
    - PayAsYouGo
    - PostPaid
    - PayOnDemand
    - Postpaid
    Default: PostPaid
    Description: 'Instance Charge type, allowed value: Prepaid and Postpaid. If specified
      Prepaid, please ensure you have sufficient balance in your account. Or instance
      creation will be failure. Default value is Postpaid.'
    Type: String
  InstanceName:
    Description: Display name of the instance, [2, 128] English or Chinese characters,
      must start with a letter or Chinese in size, can contain numbers, '_' or '.',
      '-'
    Type: String
  InstanceType:
    Description: Ecs instance supported instance type, make sure it should be correct.
    Type: String
  InternetChargeType:
    AllowedValues:
    - paybytraffic
    - PayByTraffic
    - paybybandwidth
    - PayByBandwidth
    Default: PayByTraffic
    Description: Instance internet access charge type.Support 'PayByBandwidth' and
      'PayByTraffic' only. Default is PayByTraffic
    Type: String
  InternetMaxBandwidthIn:
    Default: 200
    Description: Max internet out band width setting, unit in Mbps(Mega bit per second).
      The range is [1,200], default is 200 Mbps.
    MaxValue: 200
    MinValue: 1
    Type: Number
  InternetMaxBandwidthOut:
    Default: 1
    Description: Set internet output bandwidth of instance. Unit is Mbps(Mega bit
      per second). Range is [0,200]. Default is 1.While the property is not 0, public
      ip will be assigned for instance.
    MaxValue: 200
    MinValue: 0
    Type: Number
  IoOptimized:
    AllowedValues:
    - none
    - optimized
    Default: optimized
    Description: The 'optimized' instance can provide better IO performance. Support
      'none' and 'optimized' only, default is 'optimized'.
    Type: String
  KeyPairName:
    Description: SSH key pair name.
    Type: String
  Password:
    Description: Password of created ecs instance. Must contain at least 3 types of
      special character, lower character, upper character, number.
    Type: String
  PasswordInherit:
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Description: Specifies whether to use the password preset in the image. To use
      the PasswordInherit parameter, the Password parameter must be empty and you
      must make sure that the selected image has a password configured.
    Type: Boolean
  Period:
    AllowedValues:
    - 1
    - 2
    - 3
    - 4
    - 5
    - 6
    - 7
    - 8
    - 9
    - 12
    - 24
    - 36
    - 48
    - 60
    Default: 1
    Description: Prepaid time period. Unit is month, it could be from 1 to 9 or 12,
      24, 36, 48, 60. Default value is 1.
    Type: Number
  PeriodUnit:
    AllowedValues:
    - Week
    - Month
    - Year
    Default: Month
    Description: Unit of prepaid time period, it could be Week/Month/Year. Default
      value is Month.
    Type: String
  PrivateIpAddress:
    Description: Private IP for the instance created. Only works for VPC instance
      and cannot duplicated with existing instance.
    Type: String
  RamRoleName:
    Description: Instance RAM role name. The name is provided and maintained by Resource
      Access Management (RAM) and can be queried using ListRoles. For more information,
      see RAM API CreateRole and ListRoles.
    Type: String
  ResourceGroupId:
    Description: Resource group id.
    Type: String
  SecurityEnhancementStrategy:
    AllowedValues:
    - Active
    - Deactive
    Description: ''
    Type: String
  SecurityGroupId:
    Description: Security group to create ecs instance. For classic instance need
      the security group not belong to VPC, for VPC instance, please make sure the
      security group belong to specified VPC.
    Type: String
  SecurityGroupIds:
    Description: The ID list of security group to which to assign the instance. The
      max length is based on the maximum number of security groups to which an instance
      can belong. For more information, see the "Security group limits" section in
      Limits.
    MaxLength: 16
    MinLength: 1
    Type: Json
  SpotPriceLimit:
    Description: 'The hourly price threshold of a instance, and it takes effect only
      when parameter InstanceChargeType is PostPaid. Three decimals is allowed at
      most. '
    Type: String
  SpotStrategy:
    AllowedValues:
    - NoSpot
    - SpotWithPriceLimit
    - SpotAsPriceGo
    Description: 'The spot strategy of a Pay-As-You-Go instance, and it takes effect
      only when parameter InstanceChargeType is PostPaid. Value range: "NoSpot: A
      regular Pay-As-You-Go instance", "SpotWithPriceLimit: A price threshold for
      a spot instance, ""SpotAsPriceGo: A price that is based on the highest Pay-As-You-Go
      instance. "Default value: NoSpot.'
    Type: String
  SystemDiskCategory:
    AllowedValues:
    - cloud
    - cloud_efficiency
    - cloud_ssd
    - cloud_essd
    - ephemeral_ssd
    Default: cloud_efficiency
    Description: Category of system disk. Default is cloud_efficiency. support cloud|cloud_efficiency|cloud_ssd|cloud_essd|ephemeral_ssd
    Type: String
  SystemDiskDescription:
    Description: Description of created system disk.
    Type: String
  SystemDiskDiskName:
    Description: Name of created system disk.
    Type: String
  SystemDiskPerformanceLevel:
    Description: 'The performance level of the enhanced SSD used as the system disk.Default
      value: PL1. Valid values:PL0: A single enhanced SSD delivers up to 10,000 random
      read/write IOPS.PL1: A single enhanced SSD delivers up to 50,000 random read/write
      IOPS.PL2: A single enhanced SSD delivers up to 100,000 random read/write IOPS.PL3:
      A single enhanced SSD delivers up to 1,000,000 random read/write IOPS.'
    Type: String
  SystemDiskSize:
    Description: 'Disk size of the system disk, range from 20 to 500 GB. If you specify
      with your own image, make sure the system disk size bigger than image size. '
    MinValue: 20
    Type: Number
  Tags:
    Description: Tags to attach to instance. Max support 20 tags to add during create
      instance. Each tag with two properties Key and Value, and Key is required.
    MaxLength: 20
    Type: Json
  UserData:
    Description: User data to pass to instance. [1, 16KB] characters.User data should
      not be base64 encoded. If you want to pass base64 encoded string to the property,
      use function Fn::Base64Decode to decode the base64 string first.
    Type: String
  VSwitchId:
    Description: The vSwitch Id to create ecs instance.
    Type: String
  VpcId:
    Description: The VPC id to create ecs instance.
    Type: String
  ZoneId:
    Description: "The ID of the zone to which the instance belongs. For more information,\
      \ \ncall the DescribeZones operation to query the most recent zone list. \n\
      Default value is empty, which means random selection."
    Type: String
Resources:
  Instance:
    Properties:
      AllocatePublicIP:
        Ref: AllocatePublicIP
      AutoRenew:
        Ref: AutoRenew
      AutoRenewPeriod:
        Ref: AutoRenewPeriod
      DedicatedHostId:
        Ref: DedicatedHostId
      DeletionProtection:
        Ref: DeletionProtection
      DeploymentSetId:
        Ref: DeploymentSetId
      Description:
        Ref: Description
      DiskMappings:
        Ref: DiskMappings
      HostName:
        Ref: HostName
      HpcClusterId:
        Ref: HpcClusterId
      ImageId:
        Ref: ImageId
      InstanceChargeType:
        Ref: InstanceChargeType
      InstanceName:
        Ref: InstanceName
      InstanceType:
        Ref: InstanceType
      InternetChargeType:
        Ref: InternetChargeType
      InternetMaxBandwidthIn:
        Ref: InternetMaxBandwidthIn
      InternetMaxBandwidthOut:
        Ref: InternetMaxBandwidthOut
      IoOptimized:
        Ref: IoOptimized
      KeyPairName:
        Ref: KeyPairName
      Password:
        Ref: Password
      PasswordInherit:
        Ref: PasswordInherit
      Period:
        Ref: Period
      PeriodUnit:
        Ref: PeriodUnit
      PrivateIpAddress:
        Ref: PrivateIpAddress
      RamRoleName:
        Ref: RamRoleName
      ResourceGroupId:
        Ref: ResourceGroupId
      SecurityEnhancementStrategy:
        Ref: SecurityEnhancementStrategy
      SecurityGroupId:
        Ref: SecurityGroupId
      SecurityGroupIds:
        Ref: SecurityGroupIds
      SpotPriceLimit:
        Ref: SpotPriceLimit
      SpotStrategy:
        Ref: SpotStrategy
      SystemDiskCategory:
        Ref: SystemDiskCategory
      SystemDiskDescription:
        Ref: SystemDiskDescription
      SystemDiskDiskName:
        Ref: SystemDiskDiskName
      SystemDiskPerformanceLevel:
        Ref: SystemDiskPerformanceLevel
      SystemDiskSize:
        Ref: SystemDiskSize
      Tags:
        Ref: Tags
      UserData:
        Ref: UserData
      VSwitchId:
        Ref: VSwitchId
      VpcId:
        Ref: VpcId
      ZoneId:
        Ref: ZoneId
    Type: ALIYUN::ECS::Instance
Outputs:
  HostName:
    Description: Host name of created instance.
    Value:
      Fn::GetAtt:
      - Instance
      - HostName
  InnerIp:
    Description: Inner IP address of the specified instance. Only for classical instance.
    Value:
      Fn::GetAtt:
      - Instance
      - InnerIp
  InstanceId:
    Description: The instance ID of created ecs instance
    Value:
      Fn::GetAtt:
      - Instance
      - InstanceId
  PrimaryNetworkInterfaceId:
    Description: Primary network interface ID of created instance.
    Value:
      Fn::GetAtt:
      - Instance
      - PrimaryNetworkInterfaceId
  PrivateIp:
    Description: Private IP address of created ecs instance. Only for VPC instance.
    Value:
      Fn::GetAtt:
      - Instance
      - PrivateIp
  PublicIp:
    Description: Public IP address of created ecs instance.
    Value:
      Fn::GetAtt:
      - Instance
      - PublicIp
  SecurityGroupIds:
    Description: Security group ID list of created instance.
    Value:
      Fn::GetAtt:
      - Instance
      - SecurityGroupIds
  ZoneId:
    Description: Zone ID of created instance.
    Value:
      Fn::GetAtt:
      - Instance
      - ZoneId

更多示例,请参见创建单个ECS实例、创建SSH密钥对和绑定SSH密钥和ECS实例的组合示例:JSON示例YAML示例