All Products
Search
Document Center

Elastic Compute Service:ExportImage

Last Updated:Apr 04, 2026

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

Operation description

Before you export an image:

  • Review the prerequisites and considerations in Export an image.

  • The ImageFormat parameter is available only in the following regions: Japan (Tokyo), Indonesia (Jakarta), Germany (Frankfurt), UAE (Dubai), US (Virginia), UK (London), Singapore, Malaysia (Kuala Lumpur), and US (Silicon Valley). In regions that do not support this parameter, images are exported in the RAW format by default.

  • You must use RAM to grant ECS permissions to write to OSS. Follow these steps:

    • Create a role with the required name AliyunECSImageExportDefaultRole and attach the following trust policy:

         {
           "Statement": [
             {
               "Action": "sts:AssumeRole",
               "Effect": "Allow",
               "Principal": {
                 "Service": [
                   "ecs.aliyuncs.com"
                 ]
               }
             }
           ],
           "Version": "1"
         }
      

    • Attach the default system permission policy, AliyunECSImageExportRolePolicy, to the AliyunECSImageExportDefaultRole role. For more details, see Grant permissions to a RAM role. You can also create a custom policy that includes the following permissions:

           {
             "Version": "1",
             "Statement": [
               {
                 "Action": [
                   "oss:GetObject",
                   "oss:PutObject",
                   "oss:DeleteObject",
                   "oss:GetBucketLocation",
                   "oss:GetBucketInfo",
                   "oss:AbortMultipartUpload",
                   "oss:ListMultipartUploads",
                   "oss:ListParts"
                 ],
                 "Resource": "*",
                 "Effect": "Allow"
               }
             ]
           }
      

After the image is exported:

The custom image is stored in the specified OSS bucket. For download instructions, see Download a custom image.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:ExportImage

update

*Image

acs:ecs:{#regionId}:{#accountId}:image/{#imageId}

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the custom image. You can call DescribeRegions to view the latest list of Alibaba Cloud regions.

cn-hangzhou

ImageId

string

Yes

The ID of the custom image.

m-bp67acfmxazb4p****

OSSBucket

string

Yes

The destination OSS bucket for the exported image.

testexportImage

OSSPrefix

string

No

The prefix for the OSS object. The prefix must be 1 to 30 characters in length and can consist of letters and digits.

EcsExport

ImageFormat

string

No

The format of the exported image file. Valid values:

  • raw.

  • vhd.

  • qcow2.

  • vmdk.

  • vdi.

Default value: raw.

raw

RoleName

string

No

The name of the RAM role used to export the image.

AliyunECSImageExportDefaultRole

DryRun

boolean

No

Specifies whether to perform a dry run to check the request's validity without actually exporting the image. Valid values:

  • true: Performs a dry run. If the check succeeds, the DryRunOperation error code is returned. If the check fails, an error is returned.
  • false: Sends a normal request. If the check succeeds, the image is exported.

Default value: false.

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

C8B26B44-0189-443E-9816-D951F596****

TaskId

string

The ID of the image export task.

tsk-bp67acfmxazb4p****

RegionId

string

The region ID.

cn-hangzhou

Examples

Success response

JSON format

{
  "RequestId": "C8B26B44-0189-443E-9816-D951F596****",
  "TaskId": "tsk-bp67acfmxazb4p****",
  "RegionId": "cn-hangzhou"
}

Error codes

HTTP status code

Error code

Error message

Description

400 MissingParameter An input parameter "RegionId" that is mandatory for processing the request is not supplied.
400 InvalidImageName.Malformed The specified Image name is wrongly formed. The specified image name is invalid. The name must be 2 to 128 characters in length. It must start with a letter and cannot start with acs: or aliyun. It can contain letters, digits, periods (.), colons (:), underscores (_), and hyphens (-). It cannot contain http:// or https://.
400 InvalidOSSPrefix.Malformed The specified OSSPrefix format is wrongly formed. The specified OssPrefix parameter is invalid.
400 InvalidRegionId.NotFound The specified RegionId does not exist.
400 InvalidRegion.NotSupport The specified region does not support image import or export. The specified region does not support the operation.
400 IncorrectImageStatus The specified Image is not available.
400 InvalidImageFormat.Malformed The specified Image Format is wrongly formed. The specified image format is invalid.
400 InvalidOSSBucket.NotFound The specified OSS bucket does not exist in this region. The specified bucket does not exist.
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 InvalidOSSObject.NeedRestore The specified OSS object is a archive object, need restore first.
400 InvalidOSSBucket.NotMatched The specified OSS bucket is incorrect, %s. The specified DiskDeviceMapping.N.OSSBucket parameter is invalid. For more information, see the return value of the %s placeholder in the error message.
400 InvalidImageFormat.RegionNotSupported The specified image format is not supported in current region.
400 InvalidOSSBucket.ArchiveOssBucketNotSupported Exporting an image to an OSS bucket with Archive, Cold Archive, or Deep Cold Archive storage class is not supported. Exporting an image to an OSS bucket with Archive, Cold Archive, or Deep Cold Archive storage class is not supported.
403 ImageNotSupported The specified image from the image market, do not support export image. The specified image is an Alibaba Cloud Marketplace image and cannot be exported.
403 ImageIsExporting The specified Image is being exported. You can use the DescribeTasks API to check the status of existing tasks. The specified image is being exported. You can use the DescribeTasks API to query the status of tasks in progress.
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.
403 InvalidOSS.NotAuthorized The specified OSS bucket or object is not allowed to access. You do not have the permission to access the specified OSS bucket and object.
403 ConcurrentQuotaExceed.ExportImage %s
403 WeeklyQuotaExceed.ExportImage %s
403 InvalidImageLicense.NotSupported %s
403 InvalidImageCategory.NotSupported The specified image category is not supported. The type of mirror to which the specified mirror belongs (ImageCategory or more commonly known as ImageOwnerAlias) does not support this operation.
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 does not exist in this account. Check whether the image ID is correct.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.