Menu

4 Practical Boto3 Scripts for S3 Every DevOps Engineer Should Know
📰
0

4 Practical Boto3 Scripts for S3 Every DevOps Engineer Should Know

DEV Community·Muhammad Zubair Bin Akbar·about 1 month ago
#fTSoQ34d
#why#ai#python#boto3#bucket#print
Reading 0:00
15s threshold

Working with AWS S3 through the console is fine until you need automation, repeatability, and control. That’s where Boto3 comes in. In this post, we’ll walk through four practical Python scripts to manage S3 efficiently. ⸻ 1. List All S3 Buckets with Creation Dates A simple script to get visibility into your S3 environment. import boto3 s3 = boto3 . client ( ' s3 ' ) response = s3 . list_buckets () print ( " S3 Buckets: \n " ) for bucket in response [ ' Buckets ' ]: print ( f " Name: { bucket [ ' Name ' ] } | Created On: { bucket [ ' CreationDate ' ] } " ) Enter fullscreen mode Exit fullscreen mode Why this matters: Useful for audits, inventory tracking, or quick checks across accounts. ⸻ 2. Upload a File to S3 with Error Handling Uploading files is common but handling failures properly is what makes scripts production-ready. import boto3 from botocore.exceptions import FileNotFoundError , NoCredentialsError , ClientError s3 = boto3 .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More