All Products
Search
Document Center

Elastic Compute Service:ExportImage

Last Updated:Nov 21, 2024

Exports a custom image to an Object Storage Service (OSS) bucket in the same region.

Operation description

Take note of the following items:

  • Make sure that you are familiar with the prerequisites and considerations. For more information, see Export a custom image.

  • The ImageFormat parameter is available only for the following regions: Japan (Tokyo), Indonesia (Jakarta), Germany (Frankfurt), UAE (Dubai), US (Virginia), UK (London), Singapore, Malaysia (Kuala Lumpur), and US (Silicon Valley). By default, custom images are exported in the RAW format in regions where the ImageFormat parameter is unsupported.

  • Use Resource Access Management (RAM) to authorize Elastic Compute Service (ECS) to write data to OSS. To complete the authorization, perform the following operations:

    • Create a role named AliyunECSImageExportDefaultRole and attach the following policy to the role:

         {
           "Statement": [
             {
               "Action": "sts:AssumeRole",
               "Effect": "Allow",
               "Principal": {
                 "Service": [
                   "ecs.aliyuncs.com"
                 ]
               }
             }
           ],
           "Version": "1"
         }
      
    • Attach the AliyunECSImageExportRolePolicy system policy, which is the default policy that grants ECS the permissions to export images, to the AliyunECSImageExportDefaultRole role. 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:

Each exported custom image is stored in the specified OSS bucket. You can download the custom image. For more information, see Download OSS objects by using simple download.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
ecs:ExportImageupdate
*Image
acs:ecs:{#regionId}:{#accountId}:image/{#imageId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID of the custom image. You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
ImageIdstringYes

The custom image ID.

m-bp67acfmxazb4p****
OSSBucketstringYes

The OSS bucket in which you want to store the exported custom image.

testexportImage
OSSPrefixstringNo

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

EcsExport
ImageFormatstringNo

The format in which you want to export the custom image. Valid values:

  • raw
  • vhd
  • qcow2
  • vmdk
  • vdi

Default value: raw.

raw
RoleNamestringNo

The name of the RAM role that you want to use to export the custom image.

AliyunECSImageExportDefaultRole

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The request ID.

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

The ID of the task that is used to export the custom image.

tsk-bp67acfmxazb4p****
RegionIdstring

The region ID.

cn-hangzhou

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError messageDescription
400MissingParameterAn input parameter "RegionId" that is mandatory for processing the request is not supplied.-
400MissingParameterAn input parameter "ImageId" that is mandatory for processing the request is not supplied.-
400MissingParameterAn input parameter "OSSBucket" that is mandatory for processing the request is not supplied.-
400InvalidImageName.MalformedThe 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://.
400InvalidOSSPrefix.MalformedThe specified OSSPrefix format is wrongly formed.The specified OssPrefix parameter is invalid.
400InvalidRegionId.NotFoundThe specified RegionId does not exist.The specified region ID does not exist.
400InvalidRegion.NotSupportThe specified region does not support image import or export.The specified region does not support the operation.
400IncorrectImageStatusThe specified Image is not available.-
400InvalidImageFormat.MalformedThe specified Image Format is wrongly formed.The specified image format is invalid.
400InvalidOSSBucket.NotFoundThe specified OSS bucket does not exist in this region.The specified bucket does not exist.
400OperationDeniedThe 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.
400InvalidImage.DiskAmountOrSize%sThe 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.
400ImageNotSupportedThe specified Image contains encrypted snapshots, do not support export.The specified image contains encrypted snapshots and cannot be exported.
400InvalidOSSObject.NeedRestoreThe specified OSS object is a archive object, need restore first.-
400InvalidOSSBucket.NotMatchedThe 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.
400InvalidImage.DiskAmountOrSizeThe diskSize of the image exceeds the maximum size.-
400InvalidImageFormat.RegionNotSupportedThe specified image format is not supported in current region.-
403ImageNotSupportedThe specified image from the image market, do not support export image.The specified image is an Alibaba Cloud Marketplace image and cannot be exported.
403ImageIsExportingThe specified Image is exporting.The specified image is being exported.
403ExportImageFailedExporting image is failed, Please contact the administrator.The image cannot be exported. Contact your system administrator.
403UserNotInTheWhiteListThe user is not in the white list of exporting image.You are not authorized to export images.
403NoSetRoletoECSServiceAcountECS service account Have no right to access your OSS.please attach a role of access your oss to ECS service account.The official ECS website service account does not have permissions to access your specified OSS bucket and object.
403InvalidOSS.NotAuthorizedThe specified OSS bucket or object is not allowed to access.-
403ConcurrentQuotaExceed.ExportImage%s-
403WeeklyQuotaExceed.ExportImage%s-
403InvalidImageLicense.NotSupported%s-
403InvalidImageCategory.NotSupportedThe specified image category is not supported.-
403InvalidOSSBucket.EncryptUnsupportedAccessing objects from encrypted OSS bucket is not supported.You cannot read objects from encrypted OSS buckets.
404InvalidImageId.NotFoundThe specified ImageId does not exist.The specified image does not exist in this account. Check whether the image ID is correct.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-05-26The Error code has changedView Change Details