Exports a custom image to an OSS bucket in the same region as the custom image.

Description

  • Exporting custom mirrors created using market mirrored System Disk snapshots is not supported.
  • Supports custom mirrors that export information that includes disk snapshots in mirrors, the number of data disks cannot exceed 4, and the maximum capacity of a single data disk cannot exceed 500 GiB.
  • You need to open a ticket to contact Ali cloud to turn on export mirroring for you.

  • You are required to authorize the ECS official service account to write data to the OSS by using RAM:
    1. Create a role: AliyunECSImageExportDefaultRole (Other role names are invalid) and set the following policy to the role:
       {
         "Statement": [
           {
             "Action": "sts:AssumeRole",
             "Effect": "Allow",
             "Principal": {
               "Service": [
                 "ecs.aliyuncs.com"
               ]
             }
           }
         ],
         "Version": "1"
       }
    2. Add the default system permission policy for the role AliyunECSImageExportDefaultRole : AliyunECSImageExportRolePolicy. his policy is the default policy for ECS to provide exported images. You can also create your custom policies that must contain:
       {
         "Version": "1",
         "Statement": [
           {
             "Action": [
               "oss:GetObject",
               "oss:PutObject",
               "oss:DeleteObject",
               "oss:GetBucketLocation",
               "oss:AbortMultipartUpload",
               "oss:ListMultipartUploads",
               "oss:ListParts"
             ],
             "Resource": "*",
             "Effect": "Allow"
           }
         ]
       }

Request parameters

Name Type Required Description
Action String Yes Required parameter. Value: ExportImage.
RegionId String Yes The RegionId of the custom image. For more information, query the latest region ID list by calling DescribeRegions.
ImageId String Yes The ID of the custom image.
OssBucket String Yes The OSS bucket to which the image is to be exported.
OssPrefix String No The prefix of your OSS object name can consist a length of [1, 30] digits or letters.
ClientToken String No Used to guarantee the idempotence of the request. The value is generated by a client. It must be unique among all requests and contains a maximum of 64 ASCII characters. For more information, see How to ensure idempotence.

Response parameters

Name Type Description.
RegionId String The region ID.
ExportTaskId String The image exporting task ID.

Examples

Request example
https://ecs.aliyuncs.com/?Action=ExportImage
&RegionId=cn-hangzhou
&ImageId=m-231234567
&OssBucket=testexportImage
&<Common Request Parameters>
Response example

XML format

<ExportImageResponse>
    <RequestId>C8B26B44-0189-443E-9816-D951F59623A9</RequestId>
    <ExportTaskId>tsk-231234567</ExportTaskId>
    <RegionId>cn-hangzhou</RegionId>
</ExportImageResponse>
JSON format
{
    "RequestId": "C8B26B44-0189-443E-9816-D951F59623A9",
    "RegionId": "cn-hangzhou",
    "ExportTaskId": "tsk-231234567"
}

Error codes

The following error codes are specific to this interface. For more error codes, visit the API error center.

Error code Error message HTTP status code Meaning
Forbidden User is not authorized to operate on the specified image. 400 You are not allowed to export the image.
IncorrectImageStatus The image is not available. 400 The specified image is unavailable.
MissingParameter An input parameter RegionId that is mandatory for processing the request is not supplied. 400 The RegionId parameter is required.
MissingParameter An input parameter ImageId that is mandatory for processing the request is not supplied. 400 The ImageId parameter is required.
MissingParameter An input parameter OssBucket that is mandatory for processing the request is not supplied. 400 The OssBucket parameter is required.
OssBucket.NotFound The specified OssBucket does not exist. 400 The specified OSS bucket does not exist in the specified region.
OssPrefix.Malformed The specified OssPrefix format is incorrect. 400 The specified prefix format of OSS object is invalid.
RegionId.NotFound The specified RegionId does not exist. 400 The RegionId of the specified image does not exist.
ExportImageFailed Failed to export image. 403 Failed to export the image.
ImageId.NotFound The image does not exist. 403 The specified image ID does not exist.
ImageNotSupported The specified image is from the image market and does not support export. 403 The specified image cannot be exported because it is from the image marketplace.
InvalidRegion.NotSupport The specified region does not support image import or export. 403 The specified region temporarily does not support importing or exporting images.
OperationDenied.ImageExporting The specified image is being exported. 403 Exporting the specified image.