Home > Article > Operation and Maintenance > How to import an existing image file to the cloud server ECS and appear in the region as a custom image
The content of this article is about how to import existing image files to cloud server ECS and appear in the region as a custom image. It has certain reference value. Friends in need can refer to it. I hope It will help you.
ImportImage
Description
After importing the custom image, you can use the created custom image to create an ECS instance ( RunInstances) or replace the system disk of the instance (ReplaceSystemDisk). When calling this interface, you need to note:
You must upload the image file to the object storage OSS in advance.
The region where the image is imported must be the same as the region of the OSS Bucket where the image file is uploaded.
The value range of n in parameter DiskDeviceMapping.n is [1, 17]. When n is 1, it represents the system disk, and when n is [2, 17], it represents the data disk.
You cannot delete the image being imported, you can only cancel the import image task (CancelTask).
You need to authorize ECS to access OSS through the Access Control RAM service in advance. Refer to the following steps:
Create the role AliyunECSImageImportDefaultRole. This name must be used, otherwise importing the image will fail. The policy of the role is:
{"Statement": [ {"Action": "sts:AssumeRole","Effect": "Allow","Principal": { "Service": [ "ecs.aliyuncs.com" ] } } ],"Version": "1"}
Under this role, add the permission policy AliyunECSImageImportRolePolicy. This policy is the default policy for the ECS image import function, or you can create a custom policy. The permissions need to include:
{"Version": "1","Statement": [ {"Action": [ "oss:GetObject", "oss:GetBucketLocation"],"Resource": "*","Effect": "Allow"} ] }
Request parameters
Return parameters
Example
Request example
https://ecs.aliyuncs.com/?Action=ImportImage &RegionId=cn-hangzhou &DiskDeviceMapping.1.OSSBucket=ecsimageos &DiskDeviceMapping.1.OSSObject=CentOS_5.4_32.raw &<公共请求参数>
Return example
XML format
<ImportImageResponse> <RequestId>C8B26B44-0189-443E-9816-D951F59623A9</RequestId> <ImageId>Img-231234567</ImageId> <ImportTaskId>123-345-2332-22323</ImportTaskId> </ImportImageResponse>
JSON format
{ "RequestId": "C8B26B44-0189-443E-9816-D951F59623A9", "ImageId": "Img-231234567", "ImportTaskId":"123-345-2332-22323" }
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 import an existing image file to the cloud server ECS and appear in the region as a custom image. For more information, please follow other related articles on the PHP Chinese website!