Exports a custom image to an Object Storage Service (OSS) bucket in the same region.
Description
Before you export a custom image, complete the following operations:
- Understand the prerequisites and precautions. For more information, see Export images.
-
Use Resource Access Management (RAM) to create a RAM role for ECS and grant ECS the permissions to write data to OSS. Perform the following steps:
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 a custom image, the following situation occurs:
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 to which to export the custom image. |
OSSPrefix | String | No | EcsExport |
The prefix of the object as which to store the custom image in the OSS bucket. The prefix must be 1 to 30 characters in length and can contain digits and letters. |
ImageFormat | String | No | raw |
The format in which to export the custom image. Valid values:
Default value: raw. |
RoleName | String | No | AliyunECSImageExportDefaultRole |
The name of the RAM role to use 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
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | InvalidImageName.Malformed | The specified Image name is wrongly formed. | The error message returned because the specified image name is invalid. The name must be 2 to 128 characters in length. The name 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. | The error message returned because the specified OSSPrefix parameter is invalid. |
400 | InvalidRegionId.NotFound | The specified RegionId does not exist. | The error message returned because the specified RegionId parameter is invalid. |
400 | InvalidRegion.NotSupport | The specified region does not support image import or export. | The error message returned because the specified region does not support the operation. |
400 | IncorrectImageStatus | The specified Image is not available. | The error message returned because the specified image is in an invalid state. |
400 | InvalidImageFormat.Malformed | The specified Image Format is wrongly formed. | The error message returned because the specified ImageFormat parameter is invalid. |
400 | InvalidOSSBucket.NotFound | The specified OSS bucket does not exist in this region. | The error message returned because the specified OSS bucket does not exist. |
400 | OperationDenied | The specified image contains the snapshot of the data disk,does not support this operation. | The error message returned because the operation is not supported when the specified image contains data disk snapshots. |
400 | InvalidImage.DiskAmountOrSize | %s | The error message returned because an image cannot be exported if it contains more than four data disk snapshots or if one of its data disk snapshot exceeds 500 GiB in size. |
400 | ImageNotSupported | The specified Image contains encrypted snapshots, do not support export. | The error message returned because the specified image contains encrypted snapshots and cannot be exported. |
400 | ImageNotSupported | Image from image market does not support exporting. | The error message returned because the specified image is an Alibaba Cloud Marketplace image and cannot be exported. |
400 | InvalidOSSBucket.NotMatched | The specified OSS bucket is incorrect, %s. | The error message returned because the specified OSS bucket is invalid. 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 error message returned because the specified image is an Alibaba Cloud Marketplace image and cannot be exported. |
403 | ImageIsExporting | The specified Image is exporting. | The error message returned because the specified image is being exported. |
403 | ExportImageFailed | Exporting image is failed, Please contact the administrator. | The error message returned because the image cannot be exported. Contact a system administrator. |
403 | UserNotInTheWhiteList | The user is not in the white list of exporting image. | The error message returned because 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. | The error message returned because ECS is not authorized to access the specified OSS bucket or object. |
403 | ConcurrentQuotaExceed.ExportImage | %s | The error message returned because the maximum number of concurrent ongoing tasks has been reached. Try again later. |
403 | WeeklyQuotaExceed.ExportImage | %s | The error message returned because 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 error message returned because the specified image cannot be exported. For more information, see the return value of the %s placeholder in the error message. |
404 | InvalidImageId.NotFound | The specified ImageId does not exist. | The error message returned because the specified image does not exist in this account. Check whether the image ID is correct. |
For a list of error codes, visit the API Error Center.