Exploring Amazon S3 Operations with Python Boto3 SDK

Search for a command to run...

No comments yet. Be the first to comment.
🎬 The Story Picture this: You push code to GitHub. Five minutes later, your updated application is running in production—built, scanned for vulnerabilities, containerized, and deployed automatically. No manual steps. No human errors. Pure automation...
Building a Production-Ready GitOps CI/CD Pipeline: How Modern Companies Deploy Code 1000+ Times Per Day From Manual Deployments to Netflix-Level Automation 12 min read • DevOps • Cloud Native • Automation 🎯 The Problem Every Developer Faces Pictur...
When most people open VIM for the first time, the reaction is almost universal: “Why is this so confusing?” I felt the same—until I changed how I thought about it. VIM isn’t a typical text editor. It’s closer to cloud architecture than a traditional ...

If you're preparing for a Linux Administrator interview, here's a question you'll likely hear: "How do you patch Linux servers without internet access?" This is one of the most common interview questions, and for good reason – it's a real-world scena...

Introduction Have you ever encountered a "Permission denied" error while trying to access a file on Linux? Or wondered what those cryptic rwxr-xr-- characters mean when you run ls -l? Understanding Linux file permissions is fundamental to working wit...

Amazon Simple Storage Service (S3) is a powerful and scalable object storage service offered by Amazon Web Services (AWS). It allows developers to store and retrieve any amount of data at any time. To interact with S3 programmatically, AWS provides the Boto3 SDK for Python, which simplifies the process of integrating your applications with S3.
In this blog post, we'll explore the basic operations you can perform with S3 using the Boto3 SDK. We'll cover creating an S3 bucket, deleting a bucket, uploading a file to a bucket, and downloading a file from a bucket.
Before diving into the code, make sure you have the following prerequisites:
AWS Account: You need an AWS account with appropriate permissions to create and manage S3 resources.
AWS Access Key and Secret Key: Obtain your AWS access key and secret key from the AWS Management Console.
Boto3 Installation: Install the Boto3 library using the following command:
pip install boto3
To start using Boto3, you need to configure your AWS credentials. Create a new Python script and configure Boto3 with your AWS credentials or You can configure the AWS CLI with below given details.
Configuring the AWS Command Line Interface (CLI) is a crucial step for interacting with AWS services through the command line. The AWS CLI provides a unified tool to manage your AWS resources, and configuring it involves setting up your AWS credentials and default region. Here are the steps to configure the AWS CLI
Make sure you have the AWS CLI installed on your machine. You can download and install it from the official AWS CLI website.
Open a terminal or command prompt on your machine. The process might vary depending on your operating system.
aws configureIn the terminal or command prompt, run the following command:
aws configure
You will be prompted to enter your AWS Access Key ID. This is a unique identifier associated with your AWS account. You can obtain this key from the AWS Management Console.
AWS Access Key ID [None]: YOUR_ACCESS_KEY_ID
Next, you'll be prompted to enter your AWS Secret Access Key. This key is used to authenticate your access to AWS services.
AWS Secret Access Key [None]: YOUR_SECRET_ACCESS_KEY
This code will list down how many bucket is already created.

After Running the script you can see that there is no output because there is no bucket available.
Will create and test again the same.
No we have created the Test Bucket let see by script it will show up or not.


This code will create a New bucket.
And we have to uncomment the call function.


As you can see there is no bucket with name testbucketboto23 now i will run the code again.

After executing it created the Bucket


Again we will comment the create bucket function and uncomment the upload file function and run the code to upload the file from local to S3 bucket
Uncomment this call and function.


After running the script you can see it got uploaded

For that we will delete the file from our local system.
Now we will uncomment the download call and function


There is no file available now lets run the script.


For that we have to uncomment the function as shown below.


You can see the file has been run successfully lets see over the bucket the file got deleted or not.


Now we will uncomment the delete call and function


After executing the code the bucket got deleted make sure you have empty the bucket before deleting you can also write the function to empty the bucket.

Thank You, please share if this articles finds you insightful.