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确定系统盘的系统架构。 取值:
  • i386
  • x86_64(默认值)

Tag语法

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

Tag属性

属性名称 类型 必须 允许更新 描述 约束
Key String 标签键 长度为1~128个字符,不能以aliyunacs:开头,不能包含http://https://
Value String 标签值 长度为0~128个字符,不能以aliyunacs:开头,不能包含http://https://

DiskDeviceMapping语法

"DiskDeviceMapping": [
  {
    "Device": String,
    "SnapshotId": String,
    "Size": Integer,
    "DiskType": String
  }
]

DiskDeviceMapping属性

属性名称 类型 必须 允许更新 描述 约束
Device String 自定义镜像中的设备名称。 取值:
  • 普通云盘:/dev/xvd[a-z]。
  • 其他云盘:/dev/vd[a-z]。
SnapshotId String 根据指定的快照创建自定义镜像。
Size Integer

云盘的大小。

取值:
  • 如果没有指定SnapshotId:
    • 普通云盘Size取值范围:5~2000。

      默认值:5。

    • 其他云盘Size取值范围:20~32,768。

      默认值:20。

  • 如果指定了SnapshotId,Size取值必须大于等于SnapshotId的大小,默认值为SnapshotId的大小。

单位:GiB。

DiskType String 新镜像中的云盘类型。 您可以通过该参数使用数据盘快照做为镜像的系统盘,如果不指定,默认为快照对应的云盘类型。

取值:

  • system:系统盘。
  • data:数据盘。

返回值

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