Adds tags to or replaces the existing tags of a bucket.
Usage notes
By default, an Alibaba Cloud account has permission to add or modify bucket tags. RAM users and Security Token Service (STS) principals require the
oss:PutBucketTagspermission. For more information, see Attach a custom policy to a RAM user.Running
put-bucket-tagsreplaces all existing tags on the bucket.A bucket can have at most 20 tags. Each tag is a key-value pair.
Syntax
ossutil api put-bucket-tags --bucket <value> --tagging <value> [flags]| Parameter | Type | Description |
|---|---|---|
--bucket | string | The name of the bucket. |
--tagging | string | The tag configuration, in XML or JSON format. Use the file:// prefix to load from a file. |
This command maps to the PutBucketTags API operation. For a full list of supported flags, see Global command-line options.
--tagging format
The --tagging option accepts XML or JSON. Pass the value inline or reference a file using the file:// prefix.
XML:
<Tagging>
<TagSet>
<Tag>
<Key>string</Key>
<Value>string</Value>
</Tag>
...
</TagSet>
</Tagging>JSON:
{
"TagSet": {
"Tag": [
{
"Key": "string",
"Value": "string"
},
...
]
}
}Examples
All three examples tag examplebucket with environment=production and team=billing.
Using an XML file:
Create tagging.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Tagging>
<TagSet>
<Tag>
<Key>environment</Key>
<Value>production</Value>
</Tag>
<Tag>
<Key>team</Key>
<Value>billing</Value>
</Tag>
</TagSet>
</Tagging>ossutil api put-bucket-tags --bucket examplebucket --tagging file://tagging.xmlUsing a JSON file:
Create tagging.json:
{
"TagSet": {
"Tag": [
{
"Key": "environment",
"Value": "production"
},
{
"Key": "team",
"Value": "billing"
}
]
}
}ossutil api put-bucket-tags --bucket examplebucket --tagging file://tagging.jsonInline JSON:
ossutil api put-bucket-tags --bucket examplebucket --tagging "{\"TagSet\":{\"Tag\":[{\"Key\":\"environment\",\"Value\":\"production\"},{\"Key\":\"team\",\"Value\":\"billing\"}]}}"