tencent cloud

Tagging Bucket - bucket-tagging
Last updated: 2025-11-14 15:30:17
Tagging Bucket - bucket-tagging
Last updated: 2025-11-14 15:30:17
The bucket-tagging command is used to create (modify), get, and delete bucket tags. One bucket can have up to 50 tags.
Note:
If you need to obtain bucket tags, when you perform authorization policy, set action to cos:GetBucketTagging.
If you need to set the bucket tags, when you perform authorization policy, set action to cos:PutBucketTagging.
If you need to delete bucket tags, when you perform authorization policy, set action to cos:DeleteBucketTagging.
For more authorizations, please refer to CAM-Enabled API.

Command format

./coscli bucket-tagging --method [method] cos://<bucket-name> [tag_key]#[tag_value]
bucket-tagging includes the following parameters:
Parameter Format
Description
Sample
cos://<bucket-name>
Specify the bucket to access. You can use the bucket alias from the configuration parameters or the bucket name. If using the bucket name, you must also include the endpoint flag.
Access using bucket alias: cos://example-alias
Access using bucket name: cos://examplebucket-1250000000
The bucket-tagging command contains the following optional flags:
Flag Abbreviation
Flag Name
Description
-h
--help
View the usage of this command.
None
--method
Specify the required operations, including put (set tag), get (query tag), delete (delete tag), and add (add tag).
Note:
For other general options related to this command (such as switching buckets or user accounts), see the General Options documentation.

Setting Bucket Tags

Bucket tags are represented by a set of Key-Value pairs. Only the bucket owner and users with PutBucketTagging permissions can set bucket tags, otherwise it will return error code 403 AccessDenied.

Command format

./coscli bucket-tagging --method put cos://bucketAlias key1#value1 key2#value2
Among them, key#value represents the tag key-value pair Key-Value, where key and value are separated by #.If the bucket does not have a tag, this command will add the specified tag to the bucket; otherwise, it will overwrite the original tag.

Sample

Configure two group tags for the bucket named example-alias. One tag has key 1 and value 111, the other has key 2 and value 222. The command is as follows:
./coscli bucket-tagging --method put cos://exmaple-alias 1#111 2#222

Querying bucket tags

Command format

./coscli bucket-tagging --method get cos://bucketAlias

Sample

./coscli bucket-tagging --method get cos://exmaple-alias
The output below indicates that the bucket with the alias example-alias has two sets of tags configured. One set has a key of 1 and a value of 111, while the other set has a key of 2 and a value of 222.
KEY | VALUE
------+--------
1 | 111
2 | 222

Deleting All Bucket Tags

Command format

./coscli bucket-tagging --method delete cos://bucketAlias

Sample

./coscli bucket-tagging --method delete cos://exmaple-alias

Adding Bucket Tags

Bucket tags are represented by a set of Key-Value pairs. Only the bucket owner and users with PutBucketTagging permissions can add bucket tags, otherwise it will return error code 403 AccessDenied.

Command Syntax

./coscli bucket-tagging --method add cos://bucketAlias key1#value1 key2#value2
Among them, key#value represents the tag key-value pair Key-Value, where key and value are separated by #.

Operation Example

Add a group tag to the bucket named example-alias. The tag has key 1 and value 111. The command is as follows:
./coscli bucket-tagging --method add cos://example-alias 1#111

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback