ALIYUN::ECS::CustomImage is used to create a custom image.

Syntax

{
  "Type": "ALIYUN::ECS::CustomImage",
  "Properties": {
    "Description": String,
    "InstanceId": String,
    "ImageName": String,
    "SnapshotId": String,
    "Tag": List,
    "ResourceGroupId": String,
    "Platform": String,
    "DiskDeviceMapping": List,
    "Architecture": String,
    "ImageFamily": String,
    "SourceRegionId": String
  }
}

Properties

Property Type Required Editable Description Constraint
Description String No No The description of the custom image. The description must be 2 to 256 characters in length and cannot start with http:// or https://.
InstanceId String No No The ID of the instance. If you set this property, an Elastic Compute Service (ECS) instance is used to create the custom image. For more information, see Create a custom image from an instance.
ImageName String No No The name of the custom image. The name must be 2 to 128 characters in length. The name must start with a letter but cannot start with http:// or https://. The name can contain letters, digits, underscores (_), and hyphens (-).
SnapshotId String No No The ID of the snapshot. If you set this property, a snapshot is used to create the custom image. For more information, see Create a custom image from a snapshot.
Tag List No No The tags of the custom image. For more information, see Tag properties.
ResourceGroupId String No Yes The ID of the resource group to which the custom image belongs. None
Platform String No No The distribution of the OS for the system disk in the custom image. If you specify a data disk snapshot to create the system disk of the custom image, you must use the Platform property to specify the distribution of the OS for the system disk. Default value: Others Linux. Valid values:
  • CentOS
  • Ubuntu
  • SUSE
  • OpenSUSE
  • RedHat
  • Debian
  • CoreOS
  • Aliyun
  • Windows Server 2012
  • Windows 7
  • Customized Linux
  • Others Linux
DiskDeviceMapping List No No The mappings between images and snapshots. For more information, see DiskDeviceMapping properties.
Architecture String No No The system architecture of the system disk. If you specify a data disk snapshot to create the system disk of the custom image, you must use the Architecture property to specify the system architecture of the system disk. Default value: x86_64. Valid values:
  • i386
  • x86_64
ImageFamily String No No The name of the custom image family. The name must be 2 to 128 characters in length, and can contain letters, digits, colons(:), underscores (_), and hyphens (-). The name must start with a letter but cannot start with acs: or aliyun. The name cannot contain http:// or https://.
SourceRegionId String No No The ID of the region to which the instance or snapshot belongs. By default, the ID of the current region is used.

Tag syntax

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

Tag properties

Property Type Required Editable Description Constraint
Key String No No The tag key. The tag key must be 1 to 128 characters in length, and cannot contain http:// or https://. The tag key cannot start with acs: or aliyun.
Value String No No The tag value. The tag value must be 0 to 128 characters in length, and cannot contain http:// or https://. The tag value cannot start with acs: or aliyun.

DiskDeviceMapping syntax

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

DiskDeviceMapping properties

Property Type Required Editable Description Constraint
Device String No No The device name of the disk in the custom image. Valid values:
  • For basic disks, the system allocates a device name in alphabetical order from /dev/xvda to /dev/xvdz.
  • For disk categories other than basic disks, the system allocates a device name in alphabetical order from /dev/vda to /dev/vdz.
SnapshotId String No No The ID of the snapshot. None
Size Integer No No The size of the disk. Valid values:
  • If you do not specify the SnapshotId property:
    • Valid values for basic disks: 5 to 2000.

      Default value: 5.

    • Valid values for disk categories other than basic disks: 20 to 32768.

      Default value: 20.

  • If you specify the SnapshotId property, the value of the Size property must be greater than or equal to the value of the SnapshotId property. The default value of the Size property is the same as that of the SnapshotId property.

Unit: GiB.

DiskType String No No The type of the disk in the custom image. You can set this property to create the system disk for the custom image from a data disk snapshot. If you do not set this property, the disk type varies based on the snapshot that is used.

Valid values:

  • system: system disk
  • data: data disk

Return values

Fn::GetAtt

ImageId: the ID of the custom image.

SourceRegionId: the ID of the region to which the instance or snapshot belongs.

Examples

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
     
    "en": "Create ECS Custom Image"
  },
  "Parameters": {
    "InstanceId": {
      "Type": "String",
      "Default": "i-*****"
    },
    "ImageName": {
      "Type": "String",
      "Default": "myImageName"
    }
  },
  "Resources": {
    "CustomImage": {
      "Type": "ALIYUN::ECS::CustomImage",
      "Properties": {
        "InstanceId": {
          "Fn::GetAtt": [
            "Instance",
            "InstanceId"
          ]
        },
        "ImageName": {
          "Ref": "ImageName"
        }
      }
    }
  },
  "Outputs": {
    "ImageId": {
      "Value": {
        "Fn::GetAtt": [
          "CustomImage",
          "ImageId"
        ]
      }
    }
  }
}
            

To view more examples, visit CustomImage.json and CustomImage.yml. In the examples, the ALIYUN::ECS::CopyImage and ALIYUN::ECS::CustomImage resource types are used.