全部產品
Search
文件中心

Elastic Compute Service:TagResources - 建立並綁定標籤

更新時間:Apr 04, 2026

為指定的ECS資源清單統一建立並綁定標籤。

介面說明

介面說明

綁定標籤前,阿里雲會校正資源已有標籤數量。超過限制值後返回報錯資訊。更多資訊,請參見使用限制

調試

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

調試

授權資訊

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

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

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

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

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

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

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

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

操作

存取層級

資源類型

條件關鍵字

關聯操作

ecs:TagResources

create

DedicatedHost

acs:ecs:{#regionId}:{#accountId}:ddh/{#ddhId}

Disk

acs:ecs:{#regionId}:{#accountId}:disk/{#diskId}

NetworkInterface

acs:ecs:{#regionId}:{#accountId}:eni/{#eniId}

Image

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

Instance

acs:ecs:{#regionId}:{#accountId}:instance/{#instanceId}

KeyPair

acs:ecs:{#regionId}:{#accountId}:keypair/{#keypairId}

LaunchTemplate

acs:ecs:{#regionId}:{#accountId}:launchtemplate/{#launchtemplateId}

ReservedInstance

acs:ecs:{#regionId}:{#accountId}:reservedinstance/{#reservedinstanceId}

SecurityGroup

acs:ecs:{#regionId}:{#accountId}:securitygroup/{#securitygroupId}

Snapshot

acs:ecs:{#regionId}:{#accountId}:snapshot/{#snapshotId}

AutoSnapshotPolicy

acs:ecs:{#regionId}:{#accountId}:snapshotpolicy/{#SnapshotPolicyId}

請求參數

名稱

類型

必填

描述

樣本值

RegionId

string

資源所屬的地區 ID。您可以調用 DescribeRegions 查看最新的阿里雲地區列表。

cn-hangzhou

RegionId

string

資源所屬的地區 ID。您可以調用 DescribeRegions 查看最新的阿里雲地區列表。

cn-hangzhou

ResourceType

string

資源類型定義。取值範圍:

  • instance:ECS 執行個體。

  • disk:磁碟。

  • snapshot:快照。

  • image:鏡像。

  • securitygroup:安全性群組。

  • volume:儲存卷。

  • eni:彈性網卡。

  • ddh:Dedicated Host。

  • ddhcluster:Dedicated Host叢集。

  • keypair:SSH 金鑰對。

  • launchtemplate:啟動模板。

  • reservedinstance:預留執行個體券。

  • snapshotpolicy:自動快照策略。

  • elasticityassurance:彈性保障。

  • capacityreservation:容量預定。

  • command:雲助手命令。

  • invocation:雲助手命令執行或檔案下髮結果。

  • activation:雲助手受管理的執行個體啟用碼。

  • managedinstance:雲助手受管理的執行個體。

instance

ResourceId

array

資源 ID 數組。數組長度:1~50。

i-bp67acfmxazb4ph****

string

資源 ID。

r-XXX

Tag

array<object>

標籤數組。數組長度:1~20。如果數組中有多個標籤對象,標籤鍵Key不允許重複。

object

標籤對象。

Key

string

標籤鍵,不允許為空白和Null 字元串。最多支援 128 個字元,不能以aliyunacs:開頭,不能包含http://或者https://

TestKey

Value

string

標籤值。不允許為空白,可以為空白字串。最多支援 128 個字元,不能包含http://或者https://

TestValue

返回參數

名稱

類型

描述

樣本值

object

RequestId

string

請求 ID。

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

樣本

正常返回樣本

JSON格式

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

錯誤碼

HTTP status code

錯誤碼

錯誤資訊

描述

400 NumberExceed.ResourceIds The ResourceIds parameter's number is exceed , Valid : 50. 指定的ResourceIds參數的數量超過限制。
400 NumberExceed.Tags The Tags parameter's number is exceed , Valid : 20. 指定的標籤數量超過限制。
400 Duplicate.TagKey The Tag.N.Key contain duplicate key. 標籤中存在重複的鍵,請保持鍵的唯一性。
400 InvalidTagKey.Malformed The specified Tag.n.Key is not valid. 指定的標籤鍵參數有誤。
400 InvalidTagValue.Malformed The specified Tag.n.Value is not valid. 指定的標籤值參數有誤。
400 OperationDenied.QuotaExceed The quota of tags on resource is beyond permitted range.
400 InvalidTag.Mismatch The specified Tag.n.Key and Tag.n.Value are not match. 指定的 Tag.N.Key 和 Tag.N.Value 不匹配。
400 InvalidTagCount The specified tags are beyond the permitted range. 指定的標記超出取值範圍。
400 Invalid.Scope The specified scope is invalid.
500 ServiceUnavailable The service is unavailable, please try again later. 服務暫時不可用,請稍候重試。
403 PermissionDenied.TagOwnerBid The specified operator not have permission to set TagOwnerBid value.
403 PermissionDenied.TagOwnerUid The specified operator not have permission to set TagOwnerUid value. 無權設定標籤歸屬者。
403 PermissionDenied.Scope The specified operator not have permission to set Scope value. 指定的操作員無權設定範圍值。
403 InvalidResourceId.NotSupported The specified ResourceId does not support tagging.
403 NoPermissionKey.Scope %s
403 NoPermission.Tag The operator is not permission for the tag. 您沒有操作該資源標籤的許可權。
403 QuotaExceed.Tags %s 標籤數超過可以配置的最大數量。%s為變數,將根據調用API的實際情況動態返回錯誤資訊。
403 TagKey.Duplication The TagKey has duplication with others, case-insensitive. 指定的 Tag.N.Key 參數中存在重複的取值。該參數的取值不區分大小寫,請檢查是否傳入了重複的參數值。
404 InvalidRegionId.NotFound The RegionId provided does not exist in our records. 地區資訊錯誤
404 MissingParameter.ResourceIds The parameter - ResourceIds.N should not be null.
404 MissingParameter.TagOwnerUid The parameter - TagOwnerUid should not be null.
404 MissingParameter.TagOwnerBid The parameter - TagOwnerBid should not be null.
404 MissingParameter.ResourceType The parameter - ResourceType should not be null. 參數ResourceType不可為空。
404 MissingParameter.Tags The parameter - Tags should not be null.
404 MissingParameter.RegionId The parameter - RegionId should not be null. 必填參數RegionId為空白。
404 InvalidResourceId.NotFound The specified ResourceIds are not found in our records. 指定的資源不存在,請檢查參數 ResourceId 是否正確。
404 InvalidResourceType.NotFound The ResourceType provided does not exist in our records. 指定的資源類型不存在。

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

變更歷史

更多資訊,參考變更詳情