全部產品
Search
文件中心

Elastic Compute Service:CopyImage

更新時間:Aug 03, 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

加密映像使用的金鑰 ID。

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 參數目標地域是否設定區塊儲存帳號級加密目標映像結果結果說明
1非加密映像False 或未指定未指定未設定非加密映像不加密,映像保持原樣。
2非加密映像True未指定任意全加密映像使用者明確要求加密。如果已經設定了區塊儲存帳號級加密,則選擇設定的預設金鑰加密。否則使用服務金鑰加密。
3非加密映像True指定任意全加密映像使用者明確要求加密。使用使用者指定的 KMSKeyId 加密。
4非加密映像未指定未指定已設定全加密映像使用區塊儲存帳號級加密設定的金鑰加密。
5加密映像未指定未指定未設定加密映像保持原有的格式,不加密的快照不加密,加密的按照服務金鑰加密。
6加密映像未指定或 True未指定已設定全加密映像使用區塊儲存帳號級加密設定的金鑰加密。
7加密映像True未指定未設定全加密映像使用服務金鑰加密。
8加密映像True未指定已設定全加密映像使用區塊儲存帳號級加密設定的金鑰加密。
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"
}

錯誤碼

HTTP status code

錯誤碼

錯誤資訊

描述

400 InvalidDescription.Malformed The specified destination description is wrongly formed. 指定的參數 description 無效。
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. 指定的 Snapshot 不存在。
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. 您輸入的參數無效,請確認您的加密是否合法。%s 為變數,將根據呼叫 API 的實際情況動態返回錯誤資訊。
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. 映像名稱的長度為 2~128 個英文或中文字元。必須以大小寫字母或中文開頭,可以包含數字、半形冒號(:)、底線(_)或者連字號(-)。
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. 無法透過 OpenAPI 刪除指定的路由目錄。
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. 映像正在被複製,請使用 CancelCopyImage API。
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 年 7 月 15 日之前的快照不支援此操作。
403 OperationDenied The specified snapshot is not allowed to create image. 指定的 EIP 不可用或未獲授權。
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. 使用者不在 Arn 相關參數操作清單中。
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. ECS 服務無權限加密/解密您的 CMK 金鑰。
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. 雲端運算盒映像不支援複製。
403 OperationDenied.KMSKeyUnauthorized The operation is denied due to missing KMS key authorization. Please check the KMS key permissions and ensure the key is properly authorized for this operation.
404 InvalidImageId.NotFound The specified ImageId does not exist. 沒有找到指定的映像,請確保映像在當前區域存在或映像狀態可用。
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. 連接埠清單存在衝突的工作。

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

變更歷史

更多資訊,參考變更詳情