Exports a custom image to an Object Storage Service (OSS) bucket in the same region.
Usage notes
Before you export images, take note of the following items:
- You must make sure that you are familiar with the prerequisites and precautions. For more information, see Export images.
-
You must use Resource Access Management (RAM) to create a RAM role for Elastic Compute Service (ECS) and authorize ECS to write data to OSS. To complete the authorization, perform the following operations:
1. Create a role namedAliyunECSImageExportDefaultRole
and configure the following trust policy for the role.{ "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": [ "ecs.aliyuncs.com" ] } } ], "Version": "1" }
2. Attach theAliyunECSImageExportRolePolicy
system policy to theAliyunECSImageExportDefaultRole
role. This policy is the default policy that grants ECS the permissions to export images. For more information, go to the Cloud Resource Access Authorization page. You can also create a custom policy that contains the following content and attach the policy to the role:{ "Version": "1", "Statement": [ { "Action": [ "oss:GetObject", "oss:PutObject", "oss:DeleteObject", "oss:GetBucketLocation", "oss:GetBucketInfo", "oss:AbortMultipartUpload", "oss:ListMultipartUploads", "oss:ListParts" ], "Resource": "*", "Effect": "Allow" } ] }
After you export the images, take note of the following items:
The custom image is stored in the specified OSS bucket. You can download the custom image. For more information, see Download objects.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | ExportImage | The operation that you want to perform. Set the value to ExportImage. |
RegionId | String | Yes | cn-hangzhou | The region ID of the custom image. You can call the DescribeRegions operation to query the most recent region list. |
ImageId | String | Yes | m-bp67acfmxazb4p**** | The ID of the custom image. |
OSSBucket | String | Yes | testexportImage | The OSS bucket in which you want to store the exported custom image. |
OSSPrefix | String | No | EcsExport | The prefix of the object as which to store the custom image in the OSS bucket. It must be 1 to 30 characters in length and can contain digits and letters. |
ImageFormat | String | No | raw | The format in which you want to export the custom image. Valid values:
Default value: raw. |
RoleName | String | No | AliyunECSImageExportDefaultRole | The name of the RAM role used to export the custom image. |
Response parameters
Parameter | Type | Example | Description |
RequestId | String | C8B26B44-0189-443E-9816-D951F596**** | The ID of the request. |
TaskId | String | tsk-bp67acfmxazb4p**** | The ID of the image export task. |
RegionId | String | cn-hangzhou | The ID of the region. |
Examples
Sample requests
https://ecs.aliyuncs.com/?Action=ExportImage
&ImageId=m-bp67acfmxazb4p****
&OSSBucket=testexportImage
&RegionId=cn-hangzhou
&OSSPrefix=EcsExport
&ImageFormat=raw
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<ExportImageResponse>
<RequestId>C8B26B44-0189-443E-9816-D951F596****</RequestId>
<ExportTaskId>tsk-bp67acfmxazb4p****</ExportTaskId>
<RegionId>cn-hangzhou</RegionId>
</ExportImageResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "C8B26B44-0189-443E-9816-D951F596****",
"ExportTaskId" : "tsk-bp67acfmxazb4p****",
"RegionId" : "cn-hangzhou"
}
Error codes
HttpCode | Error code | Error message | Description |
400 | InvalidImageName.Malformed | The specified Image name is wrongly formed. | Invalid image name. The name must be 2 to 128 characters in length. It must start with a letter and cannot start with acs: or aliyun. It cannot contain http:// or https://. It can contain letters, digits, periods (.), colons (:), underscores (_), and hyphens (-). |
400 | InvalidOSSPrefix.Malformed | The specified OSSPrefix format is wrongly formed. | Invalid OSSPrefix value. |
400 | InvalidRegionId.NotFound | The specified RegionId does not exist. | Invalid RegionId value. |
400 | InvalidRegion.NotSupport | The specified region does not support image import or export. | This operation cannot be performed in the specified region. |
400 | IncorrectImageStatus | The specified Image is not available. | Invalid image state. |
400 | InvalidImageFormat.Malformed | The specified Image Format is wrongly formed. | Invalid ImageFormat value. |
400 | InvalidOSSBucket.NotFound | The specified OSS bucket does not exist in this region. | The specified OSS bucket is not found. |
400 | OperationDenied | The specified image contains the snapshot of the data disk,does not support this operation. | Images that contain data disk snapshots do not support this operation. |
400 | InvalidImage.DiskAmountOrSize | %s | The image cannot be exported because it contains more than four data disk snapshots or because one of its data disk snapshot exceeds 500 GiB in size. |
400 | ImageNotSupported | The specified Image contains encrypted snapshots, do not support export. | The specified image contains encrypted snapshots and cannot be exported. |
400 | InvalidOSSBucket.NotMatched | The specified OSS bucket is incorrect, %s. | Invalid OSS bucket. For more information, see the return value of the %s placeholder in the error message. |
403 | ImageNotSupported | The specified image from the image market, do not support export image. | The specified image is an Alibaba Cloud Marketplace image that cannot be exported. |
403 | ImageIsExporting | The specified Image is exporting. | The specified image is being exported. |
403 | ExportImageFailed | Exporting image is failed, Please contact the administrator. | The image cannot be exported. Contact your system administrator. |
403 | UserNotInTheWhiteList | The user is not in the white list of exporting image. | You are not authorized to export images. |
403 | NoSetRoletoECSServiceAcount | ECS service account Have no right to access your OSS.please attach a role of access your oss to ECS service account. | ECS is not authorized to access the specified OSS bucket or object. |
403 | ConcurrentQuotaExceed.ExportImage | %s | The maximum number of concurrent ongoing tasks is exceeded. Try again later. |
403 | WeeklyQuotaExceed.ExportImage | %s | The weekly quota for exported images of this week has been used up. Retry when the quota becomes available again. |
403 | InvalidImageLicense.NotSupported | %s | The specified image cannot be exported. For more information, see the returned value of the %s in the error message. |
403 | InvalidOSSBucket.EncryptUnsupported | Accessing objects from encrypted OSS bucket is not supported. | You cannot read objects from encrypted OSS buckets. |
404 | InvalidImageId.NotFound | The specified ImageId does not exist. | The specified image is not found in this account. Check whether the image ID is correct. |
For a list of error codes, see Service error codes.