全部產品
Search
文件中心

Elastic Compute Service:CopyImage - 複製一個地區下的自訂鏡像到其他地區

更新時間:Apr 04, 2026

複製一個地區下的自訂鏡像到其他地區。複製鏡像可以實現跨地區部署ECS執行個體、跨地區複製ECS執行個體等目的。

介面說明

介面說明

您可以在其他地區使用複製後的鏡像建立 ECS 執行個體(RunInstances),或者更換執行個體的系統硬碟(ReplaceSystemDisk)。

調用該介面時,您需要注意:

  • 自訂鏡像的狀態必須為可用(Available)。

  • 鏡像是您帳號下的自訂鏡像時,可以跨地區複製鏡像;鏡像是其他人共用給您的鏡像時,只能同地區複製鏡像。

  • 複製鏡像期間,您無法直接操作刪除( DeleteImage )複製中的鏡像,但是您可以通過取消複製任務( CancelCopyImage )的方式來刪除複製中的鏡像。

  • 同一個地區下同時只能有五個鏡像複製任務運行,其餘任務需要排隊等待上述任一任務完成後再依次排隊執行。

  • 您可以通過ResourceGroupId參數指定複製後的鏡像所屬的資源群組。如果不設定ResourceGroupId參數值,複製後的鏡像屬於預設資源群組。

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

調試

授權資訊

下表是API對應的授權資訊,可以在RAM權限原則語句的Action元素中使用,用來給RAM使用者或RAM角色授予調用此API的許可權。具體說明如下:

  • 操作:是指具體的許可權點。

  • 存取層級:是指每個操作的存取層級,取值為寫入(Write)、讀取(Read)或列出(List)。

  • 資源類型:是指操作中支援授權的資源類型。具體說明如下:

    • 對於必選的資源類型,用前面加 * 表示。

    • 對於不支援資源級授權的操作,用全部資源表示。

  • 條件關鍵字:是指雲產品自身定義的條件關鍵字。

  • 關聯操作:是指成功執行操作所需要的其他許可權。操作者必須同時具備關聯操作的許可權,操作才能成功。

操作

存取層級

資源類型

條件關鍵字

關聯操作

ecs:CopyImage

update

*Image

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

請求參數

名稱

類型

必填

描述

樣本值

DestinationImageName

string

複製後的鏡像的名稱。長度為 2~128 個字元。必須以大小寫字母或中文開頭,也不能以aliyunacs:開頭,不能包含http://或者https://。可以包含數字、半形句號(.)、半形冒號(:)、底線(_)或者短劃線(-)。

YourImageName

DestinationDescription

string

複製後的鏡像的描述資訊。長度為 2~256 個英文或中文字元,不能以http://https://開頭。

This is a description example.

ImageId

string

源自訂鏡像的 ID。

m-bp1h46wfpjsjastc****

RegionId

string

源自訂鏡像的地區 ID。您可以調用 DescribeRegions 查看最新的阿里雲地區列表。

cn-hangzhou

DestinationRegionId

string

複製到目標地區的 ID。

cn-shanghai

Encrypted

boolean

是否加密複製後的鏡像。

  • true:加密。

  • false:不加密。

  • 不指定:需要依賴後端判斷,判斷邏輯見下文的補充說明。

預設值:不指定。

false

KMSKeyId

string

加密鏡像使用的金鑰識別碼。

e522b26d-abf6-4e0d-b5da-04b7******3c

EncryptAlgorithm

string

說明

該參數暫未開放使用。

hide

ResourceGroupId

string

複製後的鏡像的資源群組 ID。如果不設定該參數值,複製後的鏡像屬於預設資源群組。

說明

如果您當前使用的是 RAM 使用者調用該介面,且ResourceGroupId取值為空白,您需要注意,當 RAM 使用者沒有預設資源群組許可權時,調用介面會返回報錯資訊Forbidden: User not authorized to operate on the specified resource。請您設定 RAM 使用者支援的資源群組 ID 或者通過相應阿里雲帳號為該 RAM 使用者授予預設資源群組許可權後,再次調用該介面。

rg-bp67acfmxazb4p****

Tag

array<object>

標籤列表。

object

標籤列表。

Value

string

複製後的鏡像的標籤值。N 的取值範圍為 1~20。一旦傳入該值,可以為空白字串。最多支援 128 個字元,不能以acs:開頭,不能包含http://https://

TestValue

Key

string

複製後的鏡像的標籤鍵。N 的取值範圍為 1~20。一旦傳入該值,則不允許為空白字串。最多支援 128 個字元,不能以aliyunacs:開頭,不能包含http://https://

TestKey

DryRun

boolean

是否只預檢此次請求。取值範圍:

  • true:發送預檢請求。檢查項包括 AccessKey 是否有效、RAM 使用者的授權情況和是否填寫了必需參數等。如果檢查不通過,則返回對應錯誤資訊。如果檢查通過,則返回錯誤碼DryRunOperation

  • false:發送正常請求,通過檢查後返回 2XX HTTP 狀態代碼並直接操作資源。

預設值:false。

false

ClientToken

string

保證請求等冪性。從您的用戶端產生一個參數值,確保不同請求間該參數值唯一。ClientToken 只支援 ASCII 字元,且不能超過 64 個字元。更多資訊,請參見如何保證等冪性

123e4567-e89b-12d3-a456-426655440000

情境源鏡像狀態Encrypted 參數KMSKeyId 參數目標地區是否配置Block Storage帳號級加密目標鏡像結果結果說明
1非加密鏡像False 或未指定未指定未配置非加密鏡像不加密,鏡像保持原樣。
2非加密鏡像True未指定任意全加密鏡像使用者顯式要求加密。如果已經配置了Block Storage帳號級加密,則選擇配置的預設祕密金鑰加密。否則使用服務祕密金鑰加密。
3非加密鏡像True指定任意全加密鏡像使用者顯式要求加密。使用使用者指定的 KMSKeyId 加密。
4非加密鏡像未指定未指定已配置全加密鏡像使用Block Storage帳號級加密配置的祕密金鑰加密。
5加密鏡像未指定未指定未配置加密鏡像保持原有的格式,不加密的快照不加密,加密的按照服務祕密金鑰加密。
6加密鏡像未指定或 True未指定已配置全加密鏡像使用Block Storage帳號級加密配置的祕密金鑰加密。
7加密鏡像True未指定未配置全加密鏡像使用服務祕密金鑰加密。
8加密鏡像True未指定已配置全加密鏡像使用Block Storage帳號級加密配置的祕密金鑰加密。
9加密鏡像True指定任意全加密鏡像使用者顯式要求加密。使用使用者指定的 KMSKeyId 加密。

返回參數

名稱

類型

描述

樣本值

object

ImageId

string

複製後的鏡像的 ID。

m-bp1h46wfpjsjastd****

RequestId

string

請求 ID。

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

樣本

正常返回樣本

JSON格式

{
  "ImageId": "m-bp1h46wfpjsjastd****",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

異常返回樣本

JSON格式

{
    "RequestId": "C8B26B44-0189-443E-9816-D951F59623A9",
    "ImageId": "Img-231234567"
}

錯誤碼

HTTP status code

錯誤碼

錯誤資訊

描述

400 InvalidDescription.Malformed The specified destination description is wrongly formed. 指定的資源描述格式不合法。長度為 2-256 個字元,不能以 http:// 和 https:// 開頭。
400 SourceRegion.NotFound The source region not found.
400 DestinationRegion.NotFound The destination region not found. 未找到目的地區
400 IncorrectImageStatus The image not available. 指定的鏡像不可用。
400 InvalidSnapshotId.NotFound The specified SnapshotId does not exist. 指定的快照不存在,請您檢查快照是否正確。
400 InvalidImageName.Duplicated The specified image name is already in use in the target region. Please try a different one. 指定的鏡像名稱已在目標地區使用。請嘗試另一個。
400 InvalidParameter.EncryptedIllegal The specified parameter Encrypted must be true when kmsKeyId is not empty. 設定參數 KMSKeyId 後,您必須開啟加密屬性。
400 InvalidEncrypted.NotMatchEncryptAlgorithm The specified parameter Encrypted must be true when EncryptAlgorithm is not empty.
400 InvalidEncryptAlgorithm The specified parameter EncryptAlgorithm is not valid.
400 InvalidEncrypted.NotMatchKmsKeyId The specified parameter Encrypted must be true when KmsKeyId is not empty.
400 OperationDenied.CommunityImage Community image does not support copy. 社區鏡像不支援複製。
400 InvalidImageName.Malformed The specified destination image name is wrongly formed. 鏡像名稱不合法。限制條件請參見 DestinationImageName 參數說明。
400 InvalidParameter.KmsNotEnabled The specified operation need enable KMS. 當前操作需要開啟KMS。
400 OperationDenied.ImageCopyConflict The same image cannot be copied concurrently. Please wait until the last copy is completed before performing the next operation. 同一鏡像不能並發拷貝,請等待上一次拷貝完成再進行下一次操作。
400 Account.Arrearage Your account has an outstanding payment. 您的帳號存在未支付的款項。
400 Duplicate.TagKey The Tag.N.Key contain duplicate key. 標籤中存在重複的鍵,請保持鍵的唯一性。
401 InvalidAliUid.IsNull The aliUid must not be null.
500 InternalError The request processing has failed due to some unknown error, exception or failure. 內部錯誤,請重試。
403 Forbbiden User not authorized to operate on the specified resource. 使用者未被授權操作指定的資源。
403 InvalidOperation.CopyingDataFromThisRegionUnsupported Data transfer from the current region to other regions is not supported. 不支援從當前地區複製資料到其他地區。
403 InvalidOperation.CopyingDataToThisRegionUnsupported Only Some Regions %s can copy data to this region. 只有某些地區可以複製資料到當前地區。
403 QuotaExceed.Image The number of images exceeds the limit (%s). 鏡像數量超過限制。
403 QuotaExceed.Snapshot The snapshot quota exceeds.
403 OperationDenied.ImageCopying The image is currently being copied. Please try again later. 鏡像正在被複製,請稍後重試。
403 RegionNotSupportCopy The region not support copy.
403 InvalidSnapshot.TooOld This operation is denied because the specified snapshot is created before 2013-07-15. 該操作被拒絕。因為指定的快照建立於 2013-07-15 之前。
403 OperationDenied The specified snapshot is not allowed to create image. 指定快照不允許建立鏡像。
403 IncorrectDestinationRegion The destination region is not equal the target region.
403 OperationDeined.EncryptedSnapshot The image contains encrypted snapshots, which do not support copying. 指定的鏡像含有加密快照,不支援複製這種鏡像。
403 OperationDenied.SameRegionOnly The image shared from others can not be copied to another region directly. 其他人分享的鏡像不能複製到另一個地區。
403 OperationDenied.NotPublished The operation is denied because corresponding marketplace image is not published in destination region. 指定的操作無法執行,鏡像的原始鏡像來自雲市場,並且未在目標地區發布。
403 OperationDenied.NotAuthorized The operation is denied because corresponding marketplace image is not authorized to current user.
403 OperationDenied.EncryptSnapshotAcrossRegion The image do not contain encrypted snapshots, which do not support copying to encrypted ones.
403 InvalidParameter.KMSKeyId.KMSUnauthorized ECS service have no right to access your KMS. ECS 服務無權訪問您的 KMS。
403 InvalidRegion.NotSupport The specified region does not support byok. 該地區不支援BYOK。
403 UserNotInTheWhiteList The user is not in byok white list. 您不在byok白名單中,請加入白名單後重試。
403 InvalidRegionId.NotSupportEncryptAlgorithm The current region does not support creating encrypted disks with EncryptAlgorithm.
403 OperationDenied.KmsServiceUnauthorized The account is not authorized to kms service, please authorize it. 使用者未授權kms服務,請先授權。
403 OperationDenied.NonCompliantDestinationRegion The copy operation to the destination region is not in compliance with regulations. 目標地區不符合安全合規要求。
403 InvalidEncrypted.NotMatchDiskDefaultEncryption The specified parameter Encrypted not match for your account default encryption settings. 加密參數不匹配當前帳號雲端硬碟預設加密配置。
403 InvalidParameter.DataEncryptedKeyCreateFailed Create kms data encrypted key fail. If you need further assistance, you can contact the KMS Technical Support. 使用KMS主要金鑰建立資料密鑰失敗,請聯絡KMS值班同學進一步排查。
403 SizeExceed.Image The image exceeds the maximum size. You can use the CopySnapshot API to copy your snapshots of the image and then create a new image from them. 鏡像的大小已超過可操作的最大值。您可以使用CopySnapshot介面複製這個鏡像的快照到目標地區,然後用複製後快照建立一個新的鏡像。
403 InvalidParameter.KMSKeyId.CMKNotEnabled The CMK (Customer Master Key) must be in an active state. 使用者主要金鑰(CMK)需要處於活動狀態。
403 InvalidParameter.KMSKeyId.CMKUnauthorized The CMK(Customer Master Key) lacks authorization to add tags to the ECS service. 使用者主要金鑰(CMK)未授權ECS服務添加標籤許可權。
403 InvalidOperation.VhdImageUnsupported The specified vhd image is not supported for this operation. Please switch to a raw image and retry. vhd格式鏡像不支援該操作,請切換使用raw格式鏡像後重試。
403 InvalidOperation.CloudBoxImageCopyUnsupported Copying CloudBox images is not supported. 雲盒鏡像不支援複製。
404 InvalidImageId.NotFound The specified ImageId does not exist. 指定的鏡像在該使用者帳號下不存在,請您檢查鏡像 ID 是否正確。
404 InvalidParameter.KMSKeyId.NotFound The specified KMSKeyId does not exist. 指定的參數 KMSKeyId 不存在。
404 InvalidResourceGroup.NotFound The ResourceGroup provided does not exist in our records. 資源群組並不在記錄中。
409 InvalidOperation.Conflict Request was denied due to conflict with a previous request, please try again later. 請求操作的資源與之前的請求衝突

訪問錯誤中心查看更多錯誤碼。

變更歷史

更多資訊,參考變更詳情