All Products
Search
Document Center

Elastic Compute Service:TagResources

Last Updated:Jun 12, 2026

Membuat dan menyambungkan tag ke resource ECS tertentu dalam satu operasi.

Deskripsi operasi

Deskripsi operasi

Sebelum Anda menyambungkan tag, Alibaba Cloud memeriksa jumlah tag yang ada pada resource. Jika jumlah tag maksimum terlampaui, pesan error akan dikembalikan. Untuk informasi lebih lanjut, lihat Batas.

Coba sekarang

Coba API ini di OpenAPI Explorer tanpa perlu penandatanganan manual. Panggilan yang berhasil akan secara otomatis menghasilkan contoh kode SDK sesuai dengan parameter Anda. Unduh kode tersebut dengan kredensial bawaan yang aman untuk penggunaan lokal.

Test

RAM authorization

Tabel berikut menjelaskan otorisasi yang diperlukan untuk memanggil API ini. Anda dapat menentukannya dalam kebijakan Resource Access Management (RAM). Kolom pada tabel dijelaskan sebagai berikut:

  • Action: Aksi yang dapat digunakan dalam elemen Action pada pernyataan kebijakan izin RAM untuk memberikan izin guna melakukan operasi tersebut.

  • API: API yang dapat Anda panggil untuk melakukan aksi tersebut.

  • Access level: Tingkat akses yang telah ditentukan untuk setiap API. Nilai yang valid: create, list, get, update, dan delete.

  • Resource type: Jenis resource yang mendukung otorisasi untuk melakukan aksi tersebut. Ini menunjukkan apakah aksi tersebut mendukung izin tingkat resource. Resource yang ditentukan harus kompatibel dengan aksi tersebut. Jika tidak, kebijakan tersebut tidak akan berlaku.

    • Untuk API dengan izin tingkat resource, jenis resource yang diperlukan ditandai dengan tanda bintang (*). Tentukan Nama Sumber Daya Alibaba Cloud (ARN) yang sesuai dalam elemen Resource pada kebijakan.

    • Untuk API tanpa izin tingkat resource, ditampilkan sebagai All Resources. Gunakan tanda bintang (*) dalam elemen Resource pada kebijakan.

  • Condition key: Kunci kondisi yang didefinisikan oleh layanan. Kunci ini memungkinkan kontrol granular, berlaku baik hanya untuk aksi maupun untuk aksi yang terkait dengan resource tertentu. Selain kunci kondisi spesifik layanan, Alibaba Cloud menyediakan serangkaian common condition keys yang berlaku di semua layanan yang didukung RAM.

  • Dependent action: Aksi dependen yang diperlukan untuk menjalankan aksi tersebut. Untuk menyelesaikan aksi tersebut, pengguna RAM atau role RAM harus memiliki izin untuk melakukan semua aksi dependen.

Action

Access level

Resource type

Condition key

Dependent action

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}

None None

Parameter permintaan

Parameter

Type

Required

Description

Example

RegionId

string

Yes

ID wilayah tempat resource berada. Anda dapat memanggil DescribeRegions untuk melihat daftar wilayah Alibaba Cloud terbaru.

cn-hangzhou

RegionId

string

Yes

资源所属的地域 ID。您可以调用 DescribeRegions 查看最新的阿里云地域列表。

cn-hangzhou

ResourceType

string

Yes

Tipe resource. Nilai valid:

  • instance: Instans ECS.

  • disk: cloud disk.

  • snapshot: snapshot.

  • image: image.

  • securitygroup: grup keamanan.

  • volume: volume penyimpanan.

  • eni: Elastic Network Interface (ENI).

  • ddh: host khusus.

  • ddhcluster: kluster host khusus.

  • keypair: pasangan kunci SSH.

  • launchtemplate: template peluncuran.

  • reservedinstance: Instans terjadwal.

  • snapshotpolicy: kebijakan snapshot otomatis.

  • elasticityassurance: jaminan elastisitas.

  • capacityreservation: reservasi kapasitas.

  • command: perintah Asisten Cloud.

  • invocation: hasil eksekusi perintah atau transfer file Asisten Cloud.

  • activation: kode aktivasi instans terkelola Asisten Cloud.

  • managedinstance: instans terkelola Asisten Cloud.

instance

ResourceId

array

Yes

ID resource. Panjang array: 1 hingga 50.

i-bp67acfmxazb4ph****

string

No

ID resource.

r-XXX

Tag

array<object>

Yes

Tag. Panjang array: 1 hingga 20. Jika array berisi beberapa objek tag, kunci tag Key harus unik.

object

No

Objek tag.

Key

string

Yes

Kunci tag. Kunci tag tidak boleh berupa string kosong. Panjang kunci tag dapat mencapai 128 karakter dan tidak boleh diawali dengan aliyun atau acs:. Kunci tag tidak boleh mengandung http:// atau https://.

TestKey

Value

string

Yes

Nilai tag. Nilai tag tidak boleh null tetapi dapat berupa string kosong. Panjang nilai tag dapat mencapai 128 karakter dan tidak boleh mengandung http:// atau https://.

TestValue

Elemen respons

Element

Type

Description

Example

object

RequestId

string

ID permintaan.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Contoh

Respons sukses

JSONformat

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

Kode kesalahan

HTTP status code

Error code

Error message

Description

400 NumberExceed.ResourceIds The ResourceIds parameter's number is exceed , Valid : 50.
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.
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
403 TagKey.Duplication The TagKey has duplication with others, case-insensitive.
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.
404 MissingParameter.Tags The parameter - Tags should not be null.
404 MissingParameter.RegionId The parameter - RegionId should not be null.
404 InvalidResourceId.NotFound The specified ResourceIds are not found in our records.
404 InvalidResourceType.NotFound The ResourceType provided does not exist in our records.

Lihat Error Codes untuk daftar lengkap.

Catatan rilis

Lihat Release Notes untuk daftar lengkap.