ALIYUN::ECS::InstanceGroup类型用于创建一组相同配置的ECS实例。
语法
{
"Type": "ALIYUN::ECS::InstanceGroup",
"Properties": {
"DedicatedHostId": String,
"ResourceGroupId": String,
"SystemDiskDescription": String,
"InstanceChargeType": String,
"RamRoleName": String,
"SystemDiskPerformanceLevel": String,
"ImageId": String,
"SystemDiskDiskName": String,
"Tags": List,
"HostName": String,
"LaunchTemplateName": String,
"VSwitchId": String,
"Period": Number,
"ZoneIds": List,
"LaunchTemplateId": String,
"DeletionProtection": Boolean,
"SecurityGroupIds": List,
"SecurityEnhancementStrategy": String,
"InternetChargeType": String,
"InstanceName": String,
"DeploymentSetId": String,
"SubscriptionDeletionForce": Boolean,
"InternetMaxBandwidthOut": Integer,
"VpcId": String,
"LaunchTemplateVersion": String,
"PeriodUnit": String,
"AutoReleaseTime": String,
"PrivateIpAddress": String,
"Description": String,
"DiskMappings": List,
"SystemDiskSize": Number,
"UserData": String,
"AutoRenew": String,
"Ipv6Addresses": List,
"MaxAmount": Integer,
"SystemDiskAutoSnapshotPolicyId": String,
"Ipv6AddressCount": Integer,
"NetworkType": String,
"SpotPriceLimit": String,
"InstanceType": String,
"AllocatePublicIP": Boolean,
"SpotStrategy": String,
"Password": String,
"PasswordInherit": Boolean,
"AutoRenewPeriod": Number,
"KeyPairName": String,
"IoOptimized": String,
"ZoneId": String,
"HpcClusterId": String,
"SecurityGroupId": String,
"SystemDiskCategory": String,
"EniMappings": List,
"SystemDiskProvisionedIops": Integer,
"SystemDiskBurstingEnabled": Boolean,
"SpotInterruptionBehavior": String,
"SpotDuration": Integer,
"UpdatePolicy": String,
"SystemDiskEncrypted": String,
"SystemDiskEncryptAlgorithm": String,
"SystemDiskStorageClusterId": String,
"SystemDiskKMSKeyId": String,
"CreditSpecification": String,
"PrivatePoolOptions": Map,
"StorageSetId": String,
"HttpTokens": String,
"HttpEndpoint": String,
"Tenancy": String,
"StorageSetPartitionNumber": Integer,
"DeploymentSetGroupNo": Integer,
"Affinity": String,
"UseAdditionalService": Boolean,
"ImageFamily": String,
"DeletionForce": Boolean,
"UniqueSuffix": Boolean,
"NetworkOptions": Map,
"CpuOptions": Map,
"NetworkInterfaceQueueNumber": Integer,
"HostNames": List,
"ImageOptions": Map,
"SecurityOptions": Map,
"SchedulerOptions": Map
}
}属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
InstanceType | String | 是 | 是 | ECS实例规格。 | 更多信息,请参见实例规格族。 说明 当UpdatePolicy取值为ForAllInstances时,才会对已有实例进行更新,否则更新该参数只针对新增实例生效。 |
MaxAmount | Integer | 是 | 是 | 一次性创建ECS实例的个数。 | 取值范围:1~1000。 说明 当更新资源栈时,如果MaxAmount取值增加(或减少),将新增(或减少)对应数量的ECS实例。例如:MaxAmount取值从2增加到5,将新增3个ECS实例。 |
AllocatePublicIP | Boolean | 否 | 否 | 是否创建公网IP。 | 如果InternetMaxBandwidthOut为0,则不会创建公网IP。 取值:
|
AutoReleaseTime | String | 否 | 否 | ECS实例自动释放的时间。 | 时间格式必须遵守ISO8601规范,例如 |
AutoRenew | String | 否 | 是 | 是否自动续费。 | 当InstanceChargeType为PrePaid时,该参数生效。 取值:
说明 更新该参数仅对新增ECS实例生效。 |
AutoRenewPeriod | Number | 否 | 是 | 每次自动续费的时长。 | 当AutoRenew为True时,该参数为必填参数。 取值:
说明 更新该参数仅对新增ECS实例生效。 |
DedicatedHostId | String | 否 | 否 | 专有宿主机ID。 | 无 |
DeletionProtection | Boolean | 否 | 是 | 实例释放保护属性,指定是否支持通过控制台或DeleteInstance接口释放实例。 | 取值:
|
DeploymentSetId | String | 否 | 是 | 部署集ID。 | 更新该参数仅对新增ECS实例生效。 |
Description | String | 否 | 是 | 描述信息。 | 最长256个字符。 说明 更新该参数仅对新增ECS实例生效。 |
DiskMappings | List | 否 | 是 | 为ECS实例创建的数据盘。 | 最多创建16块数据盘。 修改该参数,不会影响已创建的实例,新创建的实例会使用修改后的值。 更多信息,请参见DiskMappings属性。 说明 更新该参数仅对新增ECS实例生效。 |
EniMappings | List | 否 | 是 | 附加到实例的弹性网卡。 | 附加到实例的弹性网卡个数最多为1个。 更多信息,请参见EniMappings属性。 |
HostName | String | 否 | 否 | 主机名称。 | 长度最少2个字符。半角句号(.)和短划线(-)不能作为hostname的首尾字符,且不能连续使用。 更多信息,请参见请求参数。 |
HpcClusterId | String | 否 | 是 | 实例所属的HPC集群ID。 | 更新该参数仅对新增ECS实例生效。 |
ImageId | String | 否 | 是 | 用于启动ECS实例的镜像ID。包括公共镜像、自定义镜像和云市场镜像。 | 支持通过模糊的方式指定公共镜像ID,而不需要指定一个完整的公共镜像ID。例如:
更多信息,请参见请求参数。 说明 当UpdatePolicy取值为ForAllInstances时,才会对已有实例进行更新,否则更新该参数只针对新增实例生效。 |
InstanceChargeType | String | 否 | 是 | 实例的付费方式。 | 取值:
说明 更新该参数仅对新增ECS实例生效。 |
InstanceName | String | 否 | 是 | 实例名称。 | 最长为128个字符。可包含英文字母、汉字、数字、下划线(_)、半角句号(.)和短划线(-)。 通过 |
InternetChargeType | String | 否 | 是 | 公网访问带宽计费方式。 | 取值:
说明 当UpdatePolicy取值为ForAllInstances时,才会对已有实例进行更新,否则更新该参数只针对新增实例生效。 |
InternetMaxBandwidthOut | Integer | 否 | 是 | 公网出带宽最大值。 | 取值范围:0~100。 单位:Mbps。 默认值:0。 说明 当UpdatePolicy取值为ForAllInstances时,才会对已有实例进行更新,否则更新该参数只针对新增实例生效。 |
IoOptimized | String | 否 | 否 | 是否创建I/O优化实例。 | 取值:
|
Ipv6AddressCount | Integer | 否 | 是 | 为弹性网卡指定随机生成的IPv6地址数量。 | 不能同时指定Ipv6Addresses和Ipv6AddressCount。 说明 更新该参数仅对新增ECS实例生效。 |
Ipv6Addresses | List | 否 | 是 | 为弹性网卡指定IPv6地址。 | 最多指定一个IPv6地址。更改不影响现有实例。不能同时指定Ipv6Addresses和Ipv6AddressCount。 说明 更新该参数仅对新增ECS实例生效。 |
KeyPairName | String | 否 | 是 | ECS实例绑定的密钥对名称。 | 如果是Windows ECS实例,则忽略该参数。默认为空。 如果已填写KeyPairName,Password的内容仍会被设置到实例中,但是Linux系统中的密码登录方式会被禁止。 说明 更新该参数仅对新增ECS实例生效。 |
LaunchTemplateId | String | 否 | 是 | 启动模板ID。 | 无 |
LaunchTemplateName | String | 否 | 是 | 启动模板名称。 | 无 |
LaunchTemplateVersion | String | 否 | 是 | 启动模板的版本。 | 如果没有指定版本,则使用默认版本。 |
NetworkType | String | 否 | 否 | ECS实例网络类型。 | 取值:
|
Password | String | 否 | 是 | ECS实例登录密码。 | 长度为8~30个字符。必须同时包含大写英文字母、小写英文字母、数字和特殊字符其中三项,支持的特殊字符为: 如果指定Password参数,请使用HTTPS协议调用API,以免发生密码泄露。 说明 当UpdatePolicy取值为ForAllInstances时,才会对已有实例进行更新,否则更新该参数只针对新增实例生效。 |
PasswordInherit | Boolean | 否 | 否 | 是否使用镜像预设的密码。 | 取值:
说明 使用该参数时,Password参数必须为空,同时您需要确保使用的镜像已经设置了密码。 |
Period | Number | 否 | 是 | 购买资源的时长。 | 当InstanceChargeType为PrePaid时,该参数生效且为必选参数。 一旦指定了DedicatedHostId,则取值不能超过专有宿主机的订阅时长。
说明 更新该参数仅对新增ECS实例生效。 |
PeriodUnit | String | 否 | 是 | 购买资源的时长周期。 | 取值:
说明 更新该参数仅对新增ECS实例生效。 |
PrivateIpAddress | String | 否 | 否 | 实例私网IP地址。 | 专有网络类型ECS实例设置私网IP地址时,必须从交换机的空闲网段中选择。 说明 如果设置PrivateIpAddress,MaxAmount取值只能为1。 |
RamRoleName | String | 否 | 是 | 实例RAM角色名称。 | 您可以调用ListRoles查询实例RAM角色名称。 |
ResourceGroupId | String | 否 | 是 | 实例所在的资源组ID。 | 无 |
SecurityEnhancementStrategy | String | 否 | 否 | 是否启用安全加固。 | 取值:
|
SecurityGroupId | String | 否 | 否 | 新创建实例所属的安全组ID,同一个安全组内的实例之间可以互相访问。 | 不支持同时指定SecurityGroupId和SecurityGroupIds。 |
SecurityGroupIds | List | 否 | 否 | 新创建实例所属的安全组ID列表。 | 不支持同时指定SecurityGroupId和SecurityGroupIds。 更多信息,请参见安全组。 |
SpotDuration | Integer | 否 | 否 | 抢占式实例的保留时长。 | 取值范围:0~6。 单位:小时。 取值:
|
SpotInterruptionBehavior | String | 否 | 否 | 抢占实例中断模式。 | 目前仅支持Terminate(默认)直接释放实例。 |
SpotPriceLimit | String | 否 | 否 | 实例的每小时最高价格。 | 最大支持3位小数。当SpotStrategy为SpotWithPriceLimit时,该参数生效。 |
SpotStrategy | String | 否 | 是 | 后付费实例的竞价策略。 | 当InstanceChargeType为PostPaid时,该参数生效。 取值:
|
SystemDiskAutoSnapshotPolicyId | String | 否 | 是 | 系统盘自动快照策略ID。 | 无 |
SystemDiskBurstingEnabled | Boolean | 否 | 是 | 系统盘是否启用突发。 | 取值:
|
SystemDiskCategory | String | 否 | 是 | 系统盘类型。 | 取值:
说明 当UpdatePolicy取值为ForAllInstances时,才会对已有实例进行更新,否则更新该参数只针对新增实例生效。 |
SystemDiskDescription | String | 否 | 是 | 系统盘描述信息。 | 更新该参数仅对新增ECS实例生效。 |
SystemDiskDiskName | String | 否 | 是 | 系统盘名称。 | 更新该参数仅对新增ECS实例生效。 |
SystemDiskPerformanceLevel | String | 否 | 是 | 创建ESSD云盘作为系统盘使用时,设置云盘的性能等级。 | 取值:
关于如何选择ESSD性能等级,请参见ESSD云盘。 |
SystemDiskProvisionedIops | Integer | 否 | 是 | 系统盘预配的IOPS。 | 无 |
SystemDiskSize | Number | 否 | 是 | 系统盘大小。 | 取值范围:40~500。 单位:GB。 如果使用自定义镜像创建系统盘,需要保证系统盘大于自定义镜像大小。 说明 当UpdatePolicy取值为ForAllInstances时,才会对已有实例进行更新,否则更新该参数只针对新增实例生效。 |
Tags | List | 否 | 是 | 用户自定义标签。 | 最多支持20个标签,格式: 更多信息,请参见Tags属性。 |
UpdatePolicy | String | 否 | 是 | 指定更新时的策略。 | 取值:
|
UserData | String | 否 | 是 | 创建ECS实例时传递的用户数据。 | 内容需要限制在16KB以内。无需用Base64转码,特殊字符需要使用转义符。 说明 当UpdatePolicy取值为ForAllInstances时,才会对已有实例进行更新,否则更新该参数只针对新增实例生效。 |
VSwitchId | String | 否 | 否 | 交换机ID。 | 无 |
VpcId | String | 否 | 否 | 专有网络ID。 | 无 |
ZoneId | String | 否 | 否 | 可用区ID。 | 无 |
ZoneIds | List | 否 | 否 | 可用区列表。 | 无 |
DiskMappings语法
"DiskMappings": [
{
"Category": String,
"DiskName": String,
"Description": String,
"Device": String,
"SnapshotId": String,
"Size": String,
"Encrypted": String,
"KMSKeyId": String,
"PerformanceLevel": String,
"AutoSnapshotPolicyId": String,
"ProvisionedIops": Integer,
"BurstingEnabled": Boolean,
"StorageClusterId": String
}
]DiskMappings属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Size | String | 是 | 否 | 数据盘大小。 | 单位:GB。 |
Category | String | 否 | 否 | 数据盘的类型。 | 取值:
对于I/O优化实例,默认值为cloud_efficiency。 对于非I/O优化实例,默认值为cloud。 |
DiskName | String | 否 | 否 | 数据盘的名称。 | 长度为2~128个字符。必须以英文字母或汉字开头,不能以 |
Description | String | 否 | 否 | 数据盘的描述。 | 长度为2~256个字符。不能以 |
Device | String | 否 | 否 | 挂载点。 | 无 |
SnapshotId | String | 否 | 否 | 快照ID。 | 无 |
Encrypted | String | 否 | 否 | 数据盘是否加密。 | 取值:
|
KMSKeyId | String | 否 | 否 | 数据盘对应的KMS密钥ID。 | 无 |
AutoSnapshotPolicyId | String | 否 | 否 | 自动快照策略ID。 | 无 |
PerformanceLevel | String | 否 | 否 | 创建ESSD云盘作为数据盘使用时,设置云盘的性能等级。 | 取值:
关于如何选择ESSD性能等级,请参见ESSD云盘。 |
ProvisionedIops | Integer | 否 | 否 | 预配的IOPS。 | 无 |
BurstingEnabled | Boolean | 否 | 否 | 是否启用突发。 | 取值:
|
StorageClusterId | String | 否 | 否 | 专属块存储集群ID。 | 无 |
Tags语法
"Tags": [
{
"Value": String,
"Key": String
}
]Tags属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Key | String | 是 | 否 | 标签键。 | 长度为1~128个字符,不能以 |
Value | String | 否 | 否 | 标签值。 | 长度为0~128个字符,不能以 |
EniMappings语法
"EniMappings": [
{
"SecurityGroupId": String,
"VSwitchId": String,
"Description": String,
"NetworkInterfaceName": String,
"PrimaryIpAddress": String,
"InstanceType": String,
"Ipv6AddressCount": Integer,
"NetworkInterfaceTrafficMode": String,
"Ipv6Addresses": List,
"QueueNumber": Integer,
"SecurityGroupIds": List,
"NetworkInterfaceId": String,
"DeleteOnRelease": Boolean,
"NetworkCardIndex": Integer,
"QueuePairNumber": Integer
}
]EniMappings属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
SecurityGroupId | String | 否 | 是 | 安全组ID。 | 所属的安全组ID必须是同一个专有网络下的安全组。 |
VSwitchId | String | 否 | 否 | 交换机ID。 | 无 |
Description | String | 否 | 是 | 弹性网卡的描述信息。 | 长度为2~256个字符,不能以 |
NetworkInterfaceName | String | 否 | 是 | 弹性网卡名称。 | 长度为2~128个字符。必须以英文字母或汉字开头,不能以 |
PrimaryIpAddress | String | 否 | 否 | 弹性网卡的主私有IP地址。 | 指定的IP必须是在所属交换机的地址段内的空闲地址。 如果不指定IP,则默认随机分配该交换机中的空闲地址。 |
InstanceType | String | 否 | 否 | 弹性网卡类型。 | 最多设置2个网卡,设置1个弹性网卡时,支持设置1个主网卡或1个辅助网卡;设置2个弹性网卡时,仅支持同时设置1个主网卡和1个辅助网卡。 取值:
|
Ipv6AddressCount | Integer | 否 | 否 | 为主网卡指定随机生成的IPv6地址数量。 | 取值范围:1~10。 注意事项:
|
NetworkInterfaceTrafficMode | String | 否 | 否 | 网卡的通讯模式。 | 取值:
说明 RDMA模式的弹性网卡数量不能超过该实例规格族的限制。更多信息,请参见实例规格族。 |
Ipv6Addresses | List | 否 | 否 | 为主网卡指定一个或多个IPv6地址。 | 支持设置最多10个IPv6地址。 注意事项:
|
QueueNumber | Integer | 否 | 否 | 弹性网卡队列数。 | 注意事项:
|
SecurityGroupIds | List | 否 | 否 | 弹性网卡所属的一个或多个安全组ID。 | 注意事项:
|
NetworkInterfaceId | String | 否 | 否 | 随实例附加的弹性网卡ID。 | 该参数只对辅助弹性网卡生效。指定一个现有辅助弹性网卡后,您将无法配置其它网卡创建参数。 |
DeleteOnRelease | Boolean | 否 | 否 | 释放实例时是否保留网卡 | 取值:
|
NetworkCardIndex | Integer | 否 | 否 | 网卡指定的物理网卡索引。 |
|
QueuePairNumber | Integer | 否 | 否 | RDMA网卡队列数。 | 该字段类型为Long,在序列化/反序列化的过程中可能导致精度丢失,请注意数值不得大于9007199254740991。 |
PrivatePoolOptions语法
"PrivatePoolOptions": [
{
"Id": String,
"MatchCriteria": String
}
]PrivatePoolOptions属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
Id | String | 否 | 否 | 私有池ID。即弹性保障服务ID或容量预定服务ID。 | 无 |
MatchCriteria | String | 否 | 否 | 弹性保障服务或容量预定服务在生效后会生成私有池容量,供实例启动时选择。 | 取值:
以下任一场景,实例启动的私有池容量选项只能取值
|
NetworkOptions语法
"NetworkOptions": {
"EnableJumboFrame": Boolean
}NetworkOptions属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
EnableJumboFrame | Boolean | 否 | 否 | 实例是否开启Jumbo frame特性。 | 取值:
默认值:true。 说明 只有八代以上部分实例规格支持开启Jumbo frame特性。更多信息请参见巨型帧(Jumbo Frames)。 |
CpuOptions语法
"CpuOptions": {
"ThreadsPerCore": Integer,
"Core": Integer
}CpuOptions属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
ThreadsPerCore | Integer | 否 | 否 | CPU线程数。 | ECS 实例的vCPU 数= |
Core | Integer | 否 | 否 | CPU核心数。 | 该参数不支持自定义设置,只能采用默认值。 默认值:请参见更改CPU选项。 |
ImageOptions语法
"ImageOptions": {
"LoginAsNonRoot": Boolean
}ImageOptions属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
LoginAsNonRoot | Boolean | 否 | 否 | 使用该镜像的实例是否支持使用ecs-user用户登录。 | 取值:
|
SecurityOptions语法
"SecurityOptions": {
"TrustedSystemMode": String
}SecurityOptions属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
TrustedSystemMode | String | 否 | 否 | 可信系统模式。 | 取值:vTPM。目前,可信系统模式支持的实例规格族:g7、c7、r7。安全增强型(g7t、c7t、r7t)。当您创建以上实例规格族的ECS实例时,需要设置该参数。具体说明如下:如果您使用阿里云可信系统,请将该参数值设置为vTPM,在实例启动时即可通过阿里云可信系统完成可信校验。如果您不使用阿里云可信系统,可以不设置该参数值,但您需要注意,如果您所创建的ECS 实例使用了Enclave机密计算模式(SecurityOptions.ConfidentialComputingMode=Enclave),则该ECS实例也会启用可信系统。通过OpenAPI创建可信系统的ECS实例时,只能调用RunInstances实现,CreateInstance目前不支持设置SecurityOptions.TrustedSystemMode参数。 说明 如果您在创建实例的时候指定其为可信实例,那么当您更换系统盘时只能使用支持可信系统的镜像。 关于可信系统的更多信息,请参见可信计算能力概述。 |
SchedulerOptions语法
"SchedulerOptions": {
"ManagedPrivateSpaceId": String,
"DedicatedHostClusterId": String
}SchedulerOptions属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
DedicatedHostClusterId | String | 否 | 否 | 指定ECS实例所属的专有宿主机集群,系统会自动选择该专有宿主机集群中的一台专有宿主机部署ECS实例。 | 说明 仅在 在您同时指定了专有宿主机(
您可以通过DescribeDedicatedHostClusters查询专有宿主机集群 ID 列表。 |
ManagedPrivateSpaceId | String | 否 | 否 | 受管私有资源池ID。 | 无 |
返回值
Fn::GetAtt
InstanceIds:实例ID,访问实例的唯一标识。由系统生成,全局唯一。
PrivateIps:VPC类型实例的私网IP列表。当NetworkType为
vpc时,该参数生效。例如:一个带有格式的JSON Array:["172.16.XX.XX", "172.16.XX.XX", … "172.16.XX.XX"],最多100个IP,用半角逗号(,)隔开。InnerIps:Classic类型实例的私网IP列表。当NetworkType为
classic时,该参数生效。例如:一个带有格式的JSON Array:["10.1.XX.XX", "10.1.XX.XX", …, "10.1.XX.XX"],最多100个IP,用半角逗号(,)隔开。PublicIps:Classic类型实例的公网IP列表。当NetworkType为
classic时,该参数生效。例如:一个带有格式的JSON Array:["42.1.XX.XX", "42.1.XX.XX", … "42.1.XX.XX"],最多100个IP,用半角逗号(,)隔开。HostNames:所有实例的主机名称列表。
OrderId:实例的订单ID列表。
ZoneIds:可用区ID。
RelatedOrderIds:已创建的 ECS 实例的相关订单 ID 列表。
Ipv6AddressIds:已创建ECS实例的IPv6地址ID列表。
说明返回类型是两层列表。如果实例没有任何IPv6地址,则列表中相应位置的元素为空。如果所有实例都没有任何IP地址,则将返回null。
Ipv6Addresses:已创建ECS实例的IPv6地址列表。
说明返回类型是两层列表。如果实例没有任何IPv6地址,则列表中相应位置的元素为空。如果所有实例都没有任何IP地址,则将返回null。
示例
场景 1 :创建两台ECS实例并实现免密登录。
ROSTemplateFormatVersion: '2015-09-01'
Description: Creates VPC ECS instance
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: 交换机可用区
en: VSwitch Availability Zone
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
Label:
en: System Disk Type
zh-cn: 系统盘类型
Description:
en: System Disk Type
zh-cn: 系统盘类型
AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
AssociationPropertyMetadata:
ZoneId: ${VSwitchZoneId}
InstanceType: ${InstanceType}
Resources:
OpsEcsInstance:
Type: ALIYUN::ECS::InstanceGroup
Properties:
MaxAmount: 1
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::Select:
- '0'
- Fn::GetAtt:
- ProdEcsInstance
- PrivateIps
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::InstanceGroup
Properties:
MaxAmount: 1
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",
"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": "交换机可用区",
"en": "VSwitch Availability Zone"
},
"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",
"Label": {
"en": "System Disk Type",
"zh-cn": "系统盘类型"
},
"Description": {
"en": "System Disk Type",
"zh-cn": "系统盘类型"
},
"AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
"AssociationPropertyMetadata": {
"ZoneId": "${VSwitchZoneId}",
"InstanceType": "${InstanceType}"
}
}
},
"Resources": {
"OpsEcsInstance": {
"Type": "ALIYUN::ECS::InstanceGroup",
"Properties": {
"MaxAmount": 1,
"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::Select": [
"0",
{
"Fn::GetAtt": [
"ProdEcsInstance",
"PrivateIps"
]
}
]
},
"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::InstanceGroup",
"Properties": {
"MaxAmount": 1,
"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实例并更新实例配置
UpdatePolicy简介
当我们使用ALIYUN::ECS::InstanceGroup创建一组ECS实例后,需要对已创建的这组ECS进行配置批量更新时,可以使用UpdatePolicy属性去完成对ECS实例配置更新策略的控制。UpdatePolicy属性语法参考:
UpdatePolicy语法
"UpdatePolicy": {
"RollingUpdateForOrigInstances": Map
}UpdatePolicy属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
RollingUpdateForOrigInstances | Map | 否 | 是 | 控制更新已有的ECS实例的策略。 该策略内容对新增的ECS不会生效。 |
RollingUpdateForOrigInstances语法
"RollingUpdateForOrigInstances": {
"MaxBatchSize": Integer,
"PauseTime": Integer
}RollingUpdateForOrigInstances属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
MaxBatchSize | Integer | 是 | 是 | 每个批次更新的ECS实例数量。 | 取值范围:1~1000。 |
PauseTime | Integer | 否 | 是 | 各个批次更新之间暂停的时间(单位:秒)默认为0。 | 取值范围:0~3600。 |
使用以下模板创建一组相同配置的ECS实例(包含5台ECS)。
ROSTemplateFormatVersion: '2015-09-01'
Resources:
Instance:
Type: ALIYUN::ECS::InstanceGroup
Properties:
MaxAmount: 5
InstanceType: xxxx
ImageId: centos
VpcId: vpc-2xxxx
VSwitchId: vsw-xxxx
SecurityGroupId: sg-xxxxx
Password: Ros1gregrge2345
InstanceChargeType: PostPaid
NetworkType: vpc
SystemDiskCategory: xxx
SystemDiskSize: 100
InternetMaxBandwidthOut: 5
AllocatePublicIP: true
{
"ROSTemplateFormatVersion": "2015-09-01",
"Resources": {
"Instance": {
"Type": "ALIYUN::ECS::InstanceGroup",
"Properties": {
"MaxAmount": 5,
"InstanceType": "xxxx",
"ImageId": "centos",
"VpcId": "vpc-2xxxx",
"VSwitchId": "vsw-xxxx",
"SecurityGroupId": "sg-xxxxx",
"Password": "Ros1gregrge2345",
"InstanceChargeType": "PostPaid",
"NetworkType": "vpc",
"SystemDiskCategory": "xxx",
"SystemDiskSize": 100,
"InternetMaxBandwidthOut": 5,
"AllocatePublicIP": true
}
}
}
}创建资源栈成功后对已创建的ECS实例进行配置更新,更新时可以配置UpdatePolicy属性。
ROSTemplateFormatVersion: '2015-09-01'
Resources:
Instance:
Type: ALIYUN::ECS::InstanceGroup
UpdatePolicy:
RollingUpdateForOrigInstances:
MaxBatchSize: 2
PauseTime: 0
Properties:
MaxAmount: 10
InstanceType: xxxx
ImageId: centos
VpcId: vpc-2xxxx
VSwitchId: vsw-xxxx
SecurityGroupId: sg-xxxxx
Password: Ros1gregrge2345
InstanceChargeType: PostPaid
NetworkType: vpc
SystemDiskCategory: xxx
SystemDiskSize: 100
InternetMaxBandwidthOut: 5
AllocatePublicIP: true
{
"ROSTemplateFormatVersion": "2015-09-01",
"Resources": {
"Instance": {
"Type": "ALIYUN::ECS::InstanceGroup",
"UpdatePolicy": {
"RollingUpdateForOrigInstances": {
"MaxBatchSize": 2,
"PauseTime": 0
}
},
"Properties": {
"MaxAmount": 10,
"InstanceType": "xxxx",
"ImageId": "centos",
"VpcId": "vpc-2xxxx",
"VSwitchId": "vsw-xxxx",
"SecurityGroupId": "sg-xxxxx",
"Password": "Ros1gregrge2345",
"InstanceChargeType": "PostPaid",
"NetworkType": "vpc",
"SystemDiskCategory": "xxx",
"SystemDiskSize": 100,
"InternetMaxBandwidthOut": 5,
"AllocatePublicIP": true
}
}
}
}指定MaxBatchSize=2。 更新前MaxAmount=5,更新后MaxAmount=10,在更新资源栈的过程中,原有的5台机器,会分3个批次(2/2/1)进行变配更新。新增的5台机器会被一次性统一创建。
场景 3 :创建两台ECS实例并绑定至传统型负载均衡CLB服务组。
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建SLB与2个ECS实例,配置网络与安全组,将ECS实例加入SLB后端。
en: Create an SLB (Server Load Balancer) with two ECS (Elastic Compute Service) instances, configure the network and security groups, then add the ECS instances to the SLB backend.
Parameters:
SystemDiskCategory:
AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
AssociationPropertyMetadata:
InstanceType: ${ECSInstanceType}
ZoneId: ${ZoneId}
Type: String
Label:
zh-cn: 系统盘类型
en: System Disk Category
AddressType:
Default: internet
Label:
zh-cn: 网络类型
en: Address Type
Type: String
Description:
zh-cn: 负载均衡实例的网络类型,可选值:internet:公网访问,intranet:内网访问。
en: 'Network type of LoadBalancer. Optional value: Internet: public network access, Intranet: Intranet access.'
AllowedValues:
- internet
- intranet
ECSInternetChargeType:
AssociationPropertyMetadata:
LocaleKey: InternetChargeType
Description:
zh-cn: 访问公网计费方式。
en: The charge type of public internet ECS instance.
Default: PayByTraffic
Label:
zh-cn: 公网付费方式
en: Internet Charge Type
AllowedValues:
- PayByBandwidth
- PayByTraffic
Type: String
ECSInstanceType:
AssociationProperty: ALIYUN::ECS::Instance::ECSInstanceType
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.n1.large <font color='green'>2vCPU 4GiB</font>]<br></b>[ecs.n1.xlarge <font color='green'>8vCPU 16GiB</font>]<br></b>[ecs.n1.3xlarge <font color='green'>16vCPU 32GiB</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.n1.large <font color='green'>2vCPU 4GiB</font>]<br></b>[ecs.n1.xlarge <font color='green'>8vCPU 16GiB</font>]<br></b>[ecs.n1.3xlarge <font color='green'>16vCPU 32GiB</font>]
Label:
zh-cn: 实例规格
en: Instance Type
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,必须包含大写字母、小写字母、数字、特殊符号三个;<br>特殊字符包括:()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
en: The 8-30 long login password of instance, consists of the uppercase, lowercase letter and number. <br> special characters include()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
MinLength: '8'
Label:
zh-cn: 实例密码
en: Instance Password
AllowedPattern: '[0-9A-Za-z\_\-&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
NoEcho: true
MaxLength: '30'
Type: String
ImageId:
Default: centos_7_04_64_20G_alibase_201701015.vhd
AssociationProperty: ALIYUN::ECS::Image::ImageId
AssociationPropertyMetadata:
InstanceType: ${ECSInstanceType}
SupportedImageOwnerAlias:
- system
- self
- others
Type: String
Label:
zh-cn: 镜像ID
en: Image ID
Bandwidth:
Description:
zh-cn: 固定带宽计费方式的公网类型实例的带宽峰值。
en: The bandwidth peak of a public network type instance of fixed bandwidth billing.
Default: 1
MaxValue: 1000
MinValue: 1
Label:
zh-cn: 带宽峰值
en: The Peak Bandwidth
Type: Number
SLBInternetChargeType:
AssociationPropertyMetadata:
LocaleKey: InternetChargeType
Description:
zh-cn: 公网类型实例的付费方式。
en: The charge type of public internet SLB instance.
Default: paybytraffic
Label:
zh-cn: 公网付费方式
en: Internet Charge Type
AllowedValues:
- paybybandwidth
- paybytraffic
Type: String
LoadBalancerSpec:
Default: slb.s1.small
Type: String
Description:
zh-cn: 实例规格,详见:</b><a href='https://www.alibabacloud.com/help/document_detail/85939.html' target='_blank'><b><font color='blue'>性能保障型</b></font></a>
en: Instance specifications, see detail:</b><a href='https://www.alibabacloud.com/help/doc-detail/85939.html' target='_blank'><b><font color='blue'>Performance support type</b></font></a>
Label:
zh-cn: 实例规格
en: Instance Specification
ZoneId:
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
Type: String
Description:
zh-cn: 可用区ID,需确认所选可用区下是否支持ECS、VPC、VSwitch等资源。
en: The available zone ID, you should confirm the zone support ECS、VPC、VSwitch or not.
Label:
zh-cn: 可用区ID
en: Zone ID
Outputs:
BackendServerInstanceId:
Description:
zh-cn: 创建ECS的实例IDs
en: The instance IDs of create EcsInstanceGroup
Value:
Fn::GetAtt:
- EcsInstanceGroup
- InstanceIds
BackendServerPublicIp:
Description:
zh-cn: 创建ECS的实例公共IPs。
en: The instance public IPs of create EcsInstanceGroup.
Value:
Fn::GetAtt:
- EcsInstanceGroup
- PublicIps
SlbIpAddress:
Description:
zh-cn: 负载均衡器的IP地址。
en: The IP address of the load balancer.
Value:
Fn::GetAtt:
- LoadBalancer
- IpAddress
LoadBalancerId:
Description:
zh-cn: 已创建负载平衡的ID。
en: The ID of load balance created.
Value:
Fn::GetAtt:
- LoadBalancer
- LoadBalancerId
Resources:
SecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
VpcId:
Ref: Vpc
SecurityGroupName: MySecurityGroup
Attachment:
Type: ALIYUN::SLB::BackendServerAttachment
Properties:
BackendServers:
- ServerId:
Fn::Select:
- '0'
- Fn::GetAtt:
- EcsInstanceGroup
- InstanceIds
Weight: 100
- ServerId:
Fn::Select:
- '1'
- Fn::GetAtt:
- EcsInstanceGroup
- InstanceIds
Weight: 100
LoadBalancerId:
Ref: LoadBalancer
Vpc:
Type: ALIYUN::ECS::VPC
Properties:
CidrBlock: 192.168.0.0/16
EcsInstanceGroup:
Type: ALIYUN::ECS::InstanceGroup
Properties:
SystemDiskCategory:
Ref: SystemDiskCategory
VpcId:
Fn::GetAtt:
- Vpc
- VpcId
SecurityGroupId:
Fn::GetAtt:
- SecurityGroup
- SecurityGroupId
ImageId:
Ref: ImageId
IoOptimized: optimized
InternetChargeType:
Ref: ECSInternetChargeType
VSwitchId:
Ref: VSwitch
Password:
Ref: Password
InstanceType:
Ref: ECSInstanceType
MaxAmount: 2
VSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
VpcId:
Ref: Vpc
CidrBlock: 192.168.1.0/24
ZoneId:
Ref: ZoneId
LoadBalancer:
Type: ALIYUN::SLB::LoadBalancer
Properties:
InternetChargeType:
Ref: SLBInternetChargeType
Bandwidth:
Ref: Bandwidth
AddressType:
Ref: AddressType
LoadBalancerSpec:
Ref: LoadBalancerSpec
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- ZoneId
- ECSInternetChargeType
- ECSInstanceType
- ImageId
- SystemDiskCategory
- Password
Label:
default:
zh-cn: 云服务器
en: ECS
- Parameters:
- LoadBalancerSpec
- AddressType
- SLBInternetChargeType
- Bandwidth
Label:
default:
zh-cn: 负载均衡
en: SLB
{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "创建SLB与2个ECS实例,配置网络与安全组,将ECS实例加入SLB后端。",
"en": "Create an SLB (Server Load Balancer) with two ECS (Elastic Compute Service) instances, configure the network and security groups, then add the ECS instances to the SLB backend."
},
"Parameters": {
"SystemDiskCategory": {
"AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
"AssociationPropertyMetadata": {
"InstanceType": "${ECSInstanceType}",
"ZoneId": "${ZoneId}"
},
"Type": "String",
"Label": {
"zh-cn": "系统盘类型",
"en": "System Disk Category"
}
},
"AddressType": {
"Default": "internet",
"Label": {
"zh-cn": "网络类型",
"en": "Address Type"
},
"Type": "String",
"Description": {
"zh-cn": "负载均衡实例的网络类型,可选值:internet:公网访问,intranet:内网访问。",
"en": "Network type of LoadBalancer. Optional value: Internet: public network access, Intranet: Intranet access."
},
"AllowedValues": [
"internet",
"intranet"
]
},
"ECSInternetChargeType": {
"AssociationPropertyMetadata": {
"LocaleKey": "InternetChargeType"
},
"Description": {
"zh-cn": "访问公网计费方式。",
"en": "The charge type of public internet ECS instance."
},
"Default": "PayByTraffic",
"Label": {
"zh-cn": "公网付费方式",
"en": "Internet Charge Type"
},
"AllowedValues": [
"PayByBandwidth",
"PayByTraffic"
],
"Type": "String"
},
"ECSInstanceType": {
"AssociationProperty": "ALIYUN::ECS::Instance::ECSInstanceType",
"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.n1.large <font color='green'>2vCPU 4GiB</font>]<br></b>[ecs.n1.xlarge <font color='green'>8vCPU 16GiB</font>]<br></b>[ecs.n1.3xlarge <font color='green'>16vCPU 32GiB</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.n1.large <font color='green'>2vCPU 4GiB</font>]<br></b>[ecs.n1.xlarge <font color='green'>8vCPU 16GiB</font>]<br></b>[ecs.n1.3xlarge <font color='green'>16vCPU 32GiB</font>]"
},
"Label": {
"zh-cn": "实例规格",
"en": "Instance Type"
}
},
"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,必须包含大写字母、小写字母、数字、特殊符号三个;<br>特殊字符包括:()`~!@#$%^&*_-+=|{}[]:;'<>,.?/",
"en": "The 8-30 long login password of instance, consists of the uppercase, lowercase letter and number. <br> special characters include()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
},
"MinLength": "8",
"Label": {
"zh-cn": "实例密码",
"en": "Instance Password"
},
"AllowedPattern": "[0-9A-Za-z\\_\\-&:;'<>,=%`~!@#\\(\\)\\$\\^\\*\\+\\|\\{\\}\\[\\]\\.\\?\\/]+$",
"NoEcho": true,
"MaxLength": "30",
"Type": "String"
},
"ImageId": {
"Default": "centos_7_04_64_20G_alibase_201701015.vhd",
"AssociationProperty": "ALIYUN::ECS::Image::ImageId",
"AssociationPropertyMetadata": {
"InstanceType": "${ECSInstanceType}",
"SupportedImageOwnerAlias": [
"system",
"self",
"others"
]
},
"Type": "String",
"Label": {
"zh-cn": "镜像ID",
"en": "Image ID"
}
},
"Bandwidth": {
"Description": {
"zh-cn": "固定带宽计费方式的公网类型实例的带宽峰值。",
"en": "The bandwidth peak of a public network type instance of fixed bandwidth billing."
},
"Default": 1,
"MaxValue": 1000,
"MinValue": 1,
"Label": {
"zh-cn": "带宽峰值",
"en": "The Peak Bandwidth"
},
"Type": "Number"
},
"SLBInternetChargeType": {
"AssociationPropertyMetadata": {
"LocaleKey": "InternetChargeType"
},
"Description": {
"zh-cn": "公网类型实例的付费方式。",
"en": "The charge type of public internet SLB instance."
},
"Default": "paybytraffic",
"Label": {
"zh-cn": "公网付费方式",
"en": "Internet Charge Type"
},
"AllowedValues": [
"paybybandwidth",
"paybytraffic"
],
"Type": "String"
},
"LoadBalancerSpec": {
"Default": "slb.s1.small",
"Type": "String",
"Description": {
"zh-cn": "实例规格,详见:</b><a href='https://www.alibabacloud.com/help/document_detail/85939.html' target='_blank'><b><font color='blue'>性能保障型</b></font></a>",
"en": "Instance specifications, see detail:</b><a href='https://www.alibabacloud.com/help/doc-detail/85939.html' target='_blank'><b><font color='blue'>Performance support type</b></font></a>"
},
"Label": {
"zh-cn": "实例规格",
"en": "Instance Specification"
}
},
"ZoneId": {
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
"Type": "String",
"Description": {
"zh-cn": "可用区ID,需确认所选可用区下是否支持ECS、VPC、VSwitch等资源。",
"en": "The available zone ID, you should confirm the zone support ECS、VPC、VSwitch or not."
},
"Label": {
"zh-cn": "可用区ID",
"en": "Zone ID"
}
}
},
"Outputs": {
"BackendServerInstanceId": {
"Description": {
"zh-cn": "创建ECS的实例IDs",
"en": "The instance IDs of create EcsInstanceGroup"
},
"Value": {
"Fn::GetAtt": [
"EcsInstanceGroup",
"InstanceIds"
]
}
},
"BackendServerPublicIp": {
"Description": {
"zh-cn": "创建ECS的实例公共IPs。",
"en": "The instance public IPs of create EcsInstanceGroup."
},
"Value": {
"Fn::GetAtt": [
"EcsInstanceGroup",
"PublicIps"
]
}
},
"SlbIpAddress": {
"Description": {
"zh-cn": "负载均衡器的IP地址。",
"en": "The IP address of the load balancer."
},
"Value": {
"Fn::GetAtt": [
"LoadBalancer",
"IpAddress"
]
}
},
"LoadBalancerId": {
"Description": {
"zh-cn": "已创建负载平衡的ID。",
"en": "The ID of load balance created."
},
"Value": {
"Fn::GetAtt": [
"LoadBalancer",
"LoadBalancerId"
]
}
}
},
"Resources": {
"SecurityGroup": {
"Type": "ALIYUN::ECS::SecurityGroup",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"SecurityGroupName": "MySecurityGroup"
}
},
"Attachment": {
"Type": "ALIYUN::SLB::BackendServerAttachment",
"Properties": {
"BackendServers": [
{
"ServerId": {
"Fn::Select": [
"0",
{
"Fn::GetAtt": [
"EcsInstanceGroup",
"InstanceIds"
]
}
]
},
"Weight": 100
},
{
"ServerId": {
"Fn::Select": [
"1",
{
"Fn::GetAtt": [
"EcsInstanceGroup",
"InstanceIds"
]
}
]
},
"Weight": 100
}
],
"LoadBalancerId": {
"Ref": "LoadBalancer"
}
}
},
"Vpc": {
"Type": "ALIYUN::ECS::VPC",
"Properties": {
"CidrBlock": "192.168.0.0/16"
}
},
"EcsInstanceGroup": {
"Type": "ALIYUN::ECS::InstanceGroup",
"Properties": {
"SystemDiskCategory": {
"Ref": "SystemDiskCategory"
},
"VpcId": {
"Fn::GetAtt": [
"Vpc",
"VpcId"
]
},
"SecurityGroupId": {
"Fn::GetAtt": [
"SecurityGroup",
"SecurityGroupId"
]
},
"ImageId": {
"Ref": "ImageId"
},
"IoOptimized": "optimized",
"InternetChargeType": {
"Ref": "ECSInternetChargeType"
},
"VSwitchId": {
"Ref": "VSwitch"
},
"Password": {
"Ref": "Password"
},
"InstanceType": {
"Ref": "ECSInstanceType"
},
"MaxAmount": 2
}
},
"VSwitch": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"CidrBlock": "192.168.1.0/24",
"ZoneId": {
"Ref": "ZoneId"
}
}
},
"LoadBalancer": {
"Type": "ALIYUN::SLB::LoadBalancer",
"Properties": {
"InternetChargeType": {
"Ref": "SLBInternetChargeType"
},
"Bandwidth": {
"Ref": "Bandwidth"
},
"AddressType": {
"Ref": "AddressType"
},
"LoadBalancerSpec": {
"Ref": "LoadBalancerSpec"
}
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"ZoneId",
"ECSInternetChargeType",
"ECSInstanceType",
"ImageId",
"SystemDiskCategory",
"Password"
],
"Label": {
"default": {
"zh-cn": "云服务器",
"en": "ECS"
}
}
},
{
"Parameters": [
"LoadBalancerSpec",
"AddressType",
"SLBInternetChargeType",
"Bandwidth"
],
"Label": {
"default": {
"zh-cn": "负载均衡",
"en": "SLB"
}
}
}
]
}
}
}更多示例,请参考包含此资源的公共模板。