This article introduces how to use the created custom image to create an ECS instance or replace the instance's system disk, and focuses on the specific steps. The content of this article is compact, and I hope you can gain something from it.
CreateImage
Description
When calling this interface, you need to pay attention:
You need to wait Mirror resources can only be used after the mirror status becomes available (Available).
The OperationLocks of the ECS instance controlled by security cannot be marked as "LockReason": "security".
Creation method
The following describes three methods for creating a custom image through this interface.
Method 1. If you need to create a custom image for the system disk of an instance, you only need to specify a historical snapshot ID (SnapshotId) of the instance's system disk. Among them, the specified snapshot cannot be a snapshot created before July 15, 2013 (inclusive).
Method 2. If you need to use an instance as a template, you only need to specify the instance ID (InstanceId). The status of the instance must be Running or Stopped. After the interface is called successfully, a new snapshot will be added to each disk of the instance.
Method 3. If you need to combine multiple snapshots into a mirror template, you only need to establish several disk data associations (DiskDeviceMapping). When creating a custom image through this method, you need to note:
Only one system disk snapshot can be specified, and the device name of the system disk must be /dev/xvda.
You can specify multiple data disk snapshots. Data disk device names are assigned by the system in order by default, from /dev/xvdb to /dev/xvdz, and cannot be repeated.
You don’t need to specify the SnapshotId. If not specified, an empty data disk of the specified size without any data will be created.
The specified snapshot cannot be a snapshot created before July 15, 2013 (inclusive).
Request parameters
##Return parameters
Example
Request Example
https://ecs.aliyuncs.com/?Action=CreateImage &RegionId=cn-hangzhou &SnapshotId=s-snapshot1 &ImageName=demo_image &<公共请求参数>
Return example
XML format
<CreateImageResponse> <RequestId>C8B26B44-0189-443E-9816-D951F59623A9</RequestId> <ImageId>m-63DFD5FB2</ImageId> </CreateImageResponse>
JSON format
{ "RequestId": "C8B26B44-0189-443E-9816-D951F59623A9", "ImageId": "m-63DFD5FB2" }
Error code
The following are error codes unique to this interface. For more error codes, please visit the API Error Center.The above is the detailed content of How to use the created custom image to create an ECS instance or change the system disk of the instance. For more information, please follow other related articles on the PHP Chinese website!