Skip to content

Bucket and Object Tagging

Estimated time to read: 1 minute

Bucket and Object Tagging allows you to assign metadata in the form of key-value pairs to your stored data.

These tags help you organize, manage, and automate actions on buckets and objects, improving data classification and lifecycle control.

Bucket Tagging

Set Tags

Set tags on a bucket:

aws s3api put-bucket-tagging --bucket <bucket_name> \
    --tagging 'TagSet=[
        {Key=Project,Value=Analytics},
        {Key=Department,Value=Finance}
]'

Get Tags

Get tags on a bucket:

aws s3api get-bucket-tagging --bucket <bucket_name>
---
{
    "TagSet": [
        {
            "Key": "Department",
            "Value": "Finance"
        },
        {
            "Key": "Project",
            "Value": "Analytics"
        }
    ]
}

Delete Tags

Delete tags from a bucket:

aws s3api delete-bucket-tagging --bucket <bucket_name>

Object Tagging

Set Tags

Set tags on an object:

aws s3api put-object-tagging --bucket <bucket_name> --key <object_name> \
    --tagging 'TagSet=[
        {Key=Environment,Value=Production},
        {Key=Version,Value=1.0}
]'

Get Tags

Get tags from an object:

aws s3api get-object-tagging --bucket <bucket_name> --key <object_name>

Delete Tags

Delete tags from an object:

aws s3api delete-object-tagging --bucket <bucket_name> --key <object_name>

Where can it be used for?

Bucket tags can be used for: