All Products
Search
Document Center

:CopyImage

更新时间:Dec 20, 2023

Copies a custom image from one region into another region. You can copy custom images to deploy or copy Elastic Compute Service (ECS) instances across regions.

Usage notes

After you copy a custom image to the destination region, you can use the image copy (new image) to create ECS instances by calling the RunInstances operation or replace the system disks of instances by calling the ReplaceSystemDisk operation in the destination region.

Take note of the following items:

  • Only custom images that are in the Available state can be copied.
  • Custom images that you want to copy must belong to your Alibaba Cloud account or be shared to you by others, and cannot be copied across accounts.
  • When an image is being copied, the image cannot be deleted by calling the DeleteImage operation. However, you can cancel the ongoing image copy task by calling the CancelCopyImage operation.
  • A region can have only one ongoing image copy task at a time. Other image copy tasks queue up for the current task to complete before the tasks can run in sequence.
  • You can configure ResourceGroupId to specify the resource group to which the new image belongs. If you do not configure ResourceGroupId, the new image belongs to the default resource group.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter

Type

Required

Example

Description

Action String Yes CopyImage

The operation that you want to perform. Set the value to CopyImage.

DestinationImageName String No YourImageName

The name of the new image. The name must be 2 to 128 characters in length. The name must start with a letter and cannot start with acs: or aliyun. The name cannot contain http:// or https://. The name can contain letters, digits, periods (.), colons (:), underscores (_), and hyphens (-).

DestinationDescription String No This is a description example.

The description of the new image. The description must be 2 to 256 characters in length and cannot start with http:// or https://.

ImageId String Yes m-bp1h46wfpjsjastc****

The ID of the source custom image.

RegionId String Yes cn-hangzhou

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

DestinationRegionId String No cn-shanghai

The ID of the destination region to which the source custom image is copied.

Encrypted Boolean No false

Specifies whether to encrypt the new image.

  • true
  • false

Default value: false.

KMSKeyId String No e522b26d-abf6-4e0d-b5da-04b7******3c

The ID of the key used to encrypt the new image.

EncryptAlgorithm String No hide
Note This parameter is not publicly available.
ResourceGroupId String No rg-bp67acfmxazb4p****

The ID of the resource group to which the new image belongs. If you do not specify this parameter, the new image belongs to the default resource group.

Note If you call the CopyImage operation as a Resource Access Management (RAM) user who is not authorized to manage the default resource group and do not specify the ResourceGroupId parameter, the Forbbiden: User not authorized to operate on the specified resource error message is returned. You must specify the ID of a resource group that the RAM user is authorized to manage or authorize the RAM user to manage the default resource group before you call the CopyImage operation again.
Tag.N.Key String No TestKey

The key of tag N to add to the new image. Valid values of N: 1 to 20. The tag key cannot be an empty string. The tag key can be up to 128 characters in length and cannot contain http:// or https://. The tag key cannot start with acs: or aliyun.

Tag.N.Value String No TestValue

The value of tag N to add to the new image. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in length and cannot contain http:// or https://. The tag value cannot start with acs:.

Response parameters

Parameter

Type

Example

Description

ImageId String m-bp1h46wfpjsjastd****

The ID of the new image.

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

Examples

Sample requests

http(s)://ecs.aliyuncs.com/?Action=CopyImage
&ImageId=m-bp1h46wfpjsjastc****
&RegionId=cn-hangzhou
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CopyImageResponse>
    <RequestId>C8B26B44-0189-443E-9816-D951F59623A9</RequestId>
    <ImageId>m-bp1h46wfpjsjastd****</ImageId>
</CopyImageResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "C8B26B44-0189-443E-9816-D951F59623A9",
  "ImageId" : "m-bp1h46wfpjsjastd****"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidDescription.Malformed The specified destination description is wrongly formed. Invalid DestinationDescription value. The description must be 2 to 256 characters in length and cannot start with http:// or https://.
400 SourceRegion.NotFound The source region not found. The specified source region is not found.
400 DestinationRegion.NotFound The destination region not found. The destination region is not found.
400 IncorrectImageStatus The image not available. The specified image is unavailable.
400 InvalidSnapshotId.NotFound The specified SnapshotId does not exist. The specified snapshot is not found. Check whether the image ID is correct.
400 InvalidImageName.Duplicated The destination image is exist. The image name already exists.
400 InvalidParameter.EncryptedIllegal The specified parameter Encrypted must be true when kmsKeyId is not empty. The encryption feature must be enabled after a Key Management Service (KMS) key ID is specified.
400 OperationDenied.CommunityImage Community image does not support copy. Community images cannot be copied.
400 InvalidImageName.Malformed The specified destination image name is wrongly formed. Invalid DestinationImageName value. For more information, see the description of the DestinationImageName parameter.
400 InvalidParameter.KmsNotEnabled The specified operation need enable KMS. You must activate KMS.
403 Forbbiden User not authorized to operate on the specified resource. You are not authorized to perform operations on the resource.
403 QuotaExceed.Image The Image Quota exceeds. The custom image quota is exhausted.
403 QuotaExceed.Snapshot The snapshot quota exceeds. The maximum number of snapshots is exceeded. To create snapshots, delete snapshots that are no longer needed.
403 OperationDenied.ImageCopying The Image are coping. The image is being copied. Try again later.
403 RegionNotSupportCopy The region not support copy. The specified source region or destination region does not support image copying.
403 InvalidSnapshot.TooOld This operation is denied because the specified snapshot is created before 2013-07-15. The operation is denied because the specified snapshot was created before July 15, 2013.
403 OperationDenied The specified snapshot is not allowed to create image. The specified snapshot cannot be used to create images.
403 IncorrectDestinationRegion The destination region is not equal the target region. The source region must be different from the destination region when you copy an image across regions.
403 SizeExceed.Image The image exceeds the maximum size. Please open a ticket to add the account to the white list. The maximum image size is exceeded.
403 OperationDeined.EncryptedSnapshot The image contains encrypted snapshots, which do not support copying. The specified image contains encrypted snapshots and cannot be copied.
403 OperationDenied.SameRegionOnly The image shared from others can not be copied to another region directly. Images shared by other Alibaba Cloud accounts cannot be copied to another region.
403 OperationDenied.NotPublished The operation is denied because corresponding marketplace image is not published in destination region. The operation is denied because the Alibaba Cloud Marketplace image from which the specified image is derived is not released in the destination region.
403 OperationDeined.EncryptedSnapshot The image contains encrypted snapshots, which do not support copying to non-encrypted ones. The image contains encrypted snapshots and cannot be copied to non-encrypted snapshots.
403 InvalidParameter.KMSKeyId.CMKNotEnabled The CMK needs to be enabled. The customer master key (CMK) is not enabled when the KMS key ID is specified for a disk. You can call the DescribeKey operation of KMS to query the information about the specified CMK.
403 InvalidParameter.KMSKeyId.KMSUnauthorized ECS service have no right to access your KMS. ECS is not authorized to access your KMS resources.
403 InvalidRegion.NotSupport The specified region does not support byok. The Bring Your Own Key (BYOK) feature is not supported in the specified region.
403 UserNotInTheWhiteList The user is not in byok white list. You are not authorized to use the BYOK feature. Try again after you are authorized.
403 OperationDenied.KmsServiceUnauthorized The account is not authorized to kms service, please authorize it. You are not authorized to access KMS. Apply for the permissions required to access KMS.
404 InvalidImageId.NotFound The specified ImageId does not exist. The specified image is not found in the account. Check whether the image ID is correct.
404 InvalidParameter.KMSKeyId.NotFound The specified KMSKeyId does not exist. The specified KMS key ID is not found.
404 InvalidResourceGroup.NotFound The ResourceGroup provided does not exist in our records. The resource group is not found.
500 InternalError The request processing has failed due to some unknown error, exception or failure. An internal error occurred. Try again later.

For a list of error codes, see Service error codes.