Skip to content

AWS S3 Tutorial – Manage Buckets and Files using Python

Posted on:October 1, 2023 at 05:17 AM

AWS S3 is a distributed object storage system that reliably stores and retrieves data at scale. It is popular and affordable, and many prominent organizations and small companies use it.

So, you want to learn AWS? Great! You’ve come to the right place. The first thing you’ll need is an Amazon Web Services account, which can be created here:


Once your account is set up, it’s time for some tutorials! This series of blogs will cover basic tutorials on getting an IAM User to work with S3, creating buckets, and managing files to delete those buckets.

This series of blogs covers all the basics you need to work with AWS S3 using Python. We will also cover other details from S3, like versioning, static site hosting, etc. If you are interested in such blogs, subscribe to our mailing list, and you will receive the latest blogs delivered to your email.

Creating IAM user to work with S3

First, we will create an IAM user that can work with S3. This is a mandatory step. We will need IAM users with S3 permissions to create and list S3 buckets and upload and download files to and from the S3 bucket. You can learn about this in Create IAM User to Access S3 in easy steps.

S3 Operations

Once an IAM user is set up, we can start working with AWS S3.

Creating S3 Bucket

In this step, we will learn how to create an S3 bucket using Python and AWS CLI. You can learn about this here: How to create AWS S3 Buckets using Python and AWS CLI.

Listing all buckets in AWS S3

In this tutorial, you will learn how to list all buckets in AWS S3 using Python. For more details, see List S3 buckets easily using Python and CLI.

IAM policies vs. S3 bucket ACLs vs. S3 Policies

Before diving deep into the S3 bucket and object access levels, we will learn about IAM policies, S3 Policies, and S3 Bucket ACLs, the difference between them, and when we should use one to manage access levels.

Upload Local files to an S3 bucket

Next, we will learn how to move local files from our machine to the S3 bucket. There are multiple ways to achieve this, and we have covered most of them in this blog post: 4 Easy Ways to Upload a File to S3 Using Python.

Listing objects in an S3 bucket

Now that we have files in the S3 bucket, we will learn how to list them using Python. You can read more details about this in Quickest Ways to List Files in S3 Bucket.

Managing S3 Bucket Policies

The next thing we will cover in our blog is managing S3 bucket policies. By default, all buckets have private access, which means no one can read any files from that bucket. But we can give public-read access to the S3 bucket so other users can read files from our bucket. This is necessary to share data (like videos) with the public. You can read more about this in a blog post on Working With S3 Bucket Policies Using Python.

Making S3 objects public

In the last step, we learned how to make the S3 bucket public. In this step, we will learn how to make individual S3 objects public. This is useful for making some objects from the bucket public but hiding others. You can learn more about this in How to Grant Public Read Access to S3 Objects.

Encryption for S3 Buckets

We can attach an encryption policy to S3 buckets so that any object placed in that bucket will be encrypted by default. We won’t be able to place simple data in such a bucket. This is useful when we want to enforce higher security standards. You can read more about this here: How to Manage S3 Bucket Encryption Using Python.

Deleting files from the S3 bucket

In this step, we will learn how to delete files from the S3 bucket using Python. We will also learn how to delete all files from one folder in the bucket. More details here: How to Delete Files in S3 Bucket Using Python.

Delete S3 bucket

In this last article of the series, we will learn how to delete the AWS S3 bucket. When deleting the S3 bucket first, we have to remove all files, and only then we will be able to delete the bucket from S3. You can read this here: Delete S3 Bucket Using Python and CLI.


I hope you have found this AWS S3 tutorial helpful. We have covered the basics which should help you get started with S3. We will dive deep into AWS S3 in the next series of blogs. See you there 🙂