ALIYUN::ECS::CustomImage类型用于创建自定义镜像。
语法
{
"Type": "ALIYUN::ECS::CustomImage",
"Properties": {
"Description": String,
"InstanceId": String,
"ImageName": String,
"SnapshotId": String,
"Tag": List,
"ResourceGroupId": String,
"Platform": String,
"DiskDeviceMapping": List,
"Architecture": String
}
}
属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
---|---|---|---|---|---|
Description | String | 否 | 否 | 镜像的描述。 | 长度不超过256个字符。不能以http:// 和https:// 开头。
默认值为空。 |
InstanceId | String | 否 | 否 | 实例ID。 | 指定该参数则表示使用实例创建自定义镜像。 |
ImageName | String | 否 | 否 | 镜像名称。 | 长度为2~128个字符。必须以英文字母或汉字开头,不能以http:// 和https:// 开头。可包含英文字母、汉字、数字、下划线(_)和短划线(-)。
|
SnapshotId | String | 否 | 否 | 快照ID。 | 指定该参数则表示使用快照创建自定义镜像。
如果同时指定该参数和InstanceId,则该参数将被忽略,系统会使用实例创建自定义镜像。 |
Tag | List | 否 | 否 | 标签。 | 详情请参见Tag属性。 |
ResourceGroupId | String | 否 | 否 | 自定义镜像所在的企业资源组ID。 | 无 |
Platform | String | 否 | 否 | 指定数据盘快照做镜像的系统盘后,需要通过Platform确定系统盘的操作系统发行版。 | 无 |
DiskDeviceMapping | List | 否 | 否 | 镜像和快照的关系。 | 详情请参见DiskDeviceMapping属性。 |
Architecture | String | 否 | 否 | 指定数据盘快照做镜像的系统盘后,需要通过Architecture确定系统盘的系统架构。 | 取值:
|
Tag语法
"Tag": [
{
"Key": String,
"Value": String
}
]
Tag属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
---|---|---|---|---|---|
Key | String | 否 | 否 | 标签键 | 长度为1~128个字符,不能以aliyun 和acs: 开头,不能包含http:// 或https:// 。
|
Value | String | 否 | 否 | 标签值 | 长度为0~128个字符,不能以aliyun 和acs: 开头,不能包含http:// 或https:// 。
|
DiskDeviceMapping语法
"DiskDeviceMapping": [
{
"Device": String,
"SnapshotId": String,
"Size": Integer,
"DiskType": String
}
]
DiskDeviceMapping属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
---|---|---|---|---|---|
Device | String | 否 | 否 | 自定义镜像中的设备名称。 | 取值:
|
SnapshotId | String | 否 | 否 | 根据指定的快照创建自定义镜像。 | 无 |
Size | Integer | 否 | 否 |
云盘的大小。 |
取值:
单位:GiB。 |
DiskType | String | 否 | 否 | 新镜像中的云盘类型。 | 您可以通过该参数使用数据盘快照做为镜像的系统盘,如果不指定,默认为快照对应的云盘类型。
取值:
|
返回值
Fn::GetAtt
ImageId:自定义镜像ID。
示例
JSON
格式
{
"ROSTemplateFormatVersion": "2015-09-01",
"Resources": {
"WebServer": {
"Type": "ALIYUN::ECS::InstanceGroup",
"Properties": {
"VpcId": "vpc-2zevx9ios1rszqv0a****",
"MinAmount": 1,
"SecurityGroupId": "sg-2ze7pxymaix640qr****",
"ImageId": {
"Ref": "CustomImage"
},
"IoOptimized": "optimized",
"SystemDisk_Description": "SystemDisk.Description",
"SystemDisk_DiskName": "SystemDisk.DiskName",
"SystemDisk_Category": "cloud_ssd",
"VSwitchId": "vsw-2zei67xd9nhcqxzec****",
"Password": "Wenqiao****",
"InstanceType": "ecs.n1.medium",
"MaxAmount": 1
}
},
"CustomImage": {
"Type": "ALIYUN::ECS::CustomImage",
"Properties": {
"InstanceId": "i-2zefq1f3ynnrr89q****",
"SnapshotId": "s-2ze0ibk1pvak4mw6****",
"ImageName": "image-test-****"
}
}
},
"Outputs": {
"CustomImage": {
"Value": {
"Fn::GetAtt": [
"CustomImage",
"ImageId"
]
}
},
"InstanceIds": {
"Value": {
"Fn::GetAtt": [
"WebServer",
"InstanceIds"
]
}
}
}
}
YAML
格式
ROSTemplateFormatVersion: '2015-09-01'
Resources:
WebServer:
Type: 'ALIYUN::ECS::InstanceGroup'
Properties:
VpcId: vpc-2zevx9ios1rszqv0a****
MinAmount: 1
SecurityGroupId: sg-2ze7pxymaix640qr****
ImageId:
Ref: CustomImage
IoOptimized: optimized
SystemDisk_Description: SystemDisk.Description
SystemDisk_DiskName: SystemDisk.DiskName
SystemDisk_Category: cloud_ssd
VSwitchId: vsw-2zei67xd9nhcqxzec****
Password: Wenqiao****
InstanceType: ecs.n1.medium
MaxAmount: 1
CustomImage:
Type: 'ALIYUN::ECS::CustomImage'
Properties:
InstanceId: i-2zefq1f3ynnrr89q****
SnapshotId: s-2ze0ibk1pvak4mw6****
ImageName: image-test-****
Outputs:
CustomImage:
Value:
'Fn::GetAtt':
- CustomImage
- ImageId
InstanceIds:
Value:
'Fn::GetAtt':
- WebServer
- InstanceIds