AWS S3 Tutorial – Manage Buckets and Files using Python

AWS S3 is a distributed object storage system that can be used to store and retrieve any amount of data from anywhere on the web. It is an externally popular and affordable storage solution. A lot of big organizations and people use AWS S3.

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: https://aws.amazon.com/.

aws-s3-tutorial
AWS S3

Once your account is set up, it’s time for some tutorials! This series of blogs will cover basic tutorials from how to get an IAM User to work with S3, how to create buckets, how to manage files to deleting those buckets.

This series of blogs cover all basic that you should 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 start with creating an IAM user that can work with S3. This is a mandatory step. We will need IAM users with S3 permissions to create, list S3 buckets as well as 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 we have an IAM user 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

We will learn how we can list all buckets in AWS S3 using python. More details about this List S3 buckets easily using Python and CLI.

IAM policies vs S3 bucket ACLs vs S3 Policies

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

Upload Local files to an S3 bucket

Next, we will learn how we can move local files from our machine to the S3 bucket. There are multiple ways to achieve this and we have covered most of these 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 we can 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 how to manage S3 bucket policies. By default all bucket have private access means no will be able to read any files from that bucket. But we can give public-read access to the S3 bucket so that other users can read files from our bucket. This is necessary when we want 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 we can make individual S3 objects public. This is useful when we just want to make few objects from bucket public but hide other objects. 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. You can find 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 about this here Delete S3 Bucket Using Python and CLI

Conclusion

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

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *