AWS: S3 Tagging



What is S3 Bucket?

-- Amazon Simple Storage Service (S3) is a cloud-based storage service provided by AWS. It offers scalable, durable, and highly available object storage, making it a popular choice for various applications, from data backups and content distribution to big data analytics and application hosting.


S3 operates on the concept of "buckets," which are containers for storing objects such as images, videos, documents, and other data types. Each object within a bucket is uniquely identified by a key and can be accessed through a URL.


It supports various storage classes, allowing users to optimize costs based on data access patterns. These classes include Standard, Intelligent-Tiering, Infrequent Access, Glacier etc.


-- To update or append tags in S3 bucket.


Python code using the boto3 library to change tags for an object in an Amazon S3 bucket:


import boto3


s3 = boto3.client("s3")


new_tags = [

    {'Key': 'Tag1', 'Value': 'Value1'},

    {'Key': 'Tag2', 'Value': 'Value2'},

    # Add more tags as needed

]

response = s3.put_object_tagging(

    Bucket='your-bucket-name',

    Key='your-object-key',

    Tagging={'TagSet': new_tags}

)

print(response)




Make sure you have installed the `boto3` library using `pip install boto3` before running the code. Also, ensure that your AWS credentials have sufficient permissions  update tags on the S3 object.


ECS service propagate tags short note and how to update it will be discussed in next week blog.

Thank you 🙂

Comments

Popular posts from this blog

Data analysis with R

Machine learning in Python

AWS: Config Rule & Compliance Check