Create S3 bucket using AWS CLI and Python Boto3

Today we are going to learn how to create AWS S3 bucket using AWS CLI and Python boto3 and from S3 management console. While creating S3 buckets, we need to give attention to its access permission as well as region. Access permission decides who can use this bucket and what actions are allowed for each user. The region is useful when we want low latency or save cost or when we have to follow some regulatory restrictions (Like Data in the USA should stay in USA region buckets only). Let’s get started.

S3 Bucket using AWS CLI

We can use two different commands while creating S3 bucket using CLI.

Above command create a bucket named “testbucket-fromcli-1” in S3 in us-east-1 region. We can specify access permission on the bucket using –acl parameter. ACL(Access Control List) can have one following of values.

  • “private”
  • “public-read”
  • “public-read-write”
  • “authenticated-read”

If you do not specify any ACL then by default, all S3 buckets are created with private acl applied to them.

AWS Facts

We can also use AWS S3 command to create a bucket. When using the S3 command we need to pass bucket URI instead of bucket name while creating S3 bucket.

Creating S3 bucket using Python and Boto3

Let us create a S3 bucket using Python and boto3 now. Boto3 offers client and service resource for S3. Both of them have create_bucket function command and both functions have same definition and accept the same set of parameters. We can use the following code to create a bucket using S3 client.

Once you run above code you can see output like this.

Bucket created output
Bucket created output

Here we need to pass “CreateBucketConfiguration” parameter to set bucket location.

By default bucket is created in US East (North Virginia) region.

AWS facts

Boto3 S3 service resource have similar code to create s3 bucket.

After running all above commands and python code, we can check our S3 console and verify all buckets have been created.

S3 buckets created

Creating S3 bucket on S3 management console

AWS offers simple steps to create a bucket on the S3 console as well. My issue with S3 console is, it keeps changing whereas CLI stays the same. Anyways, you can check below to know how to create an S3 bucket on the console. I will try to keep this updated if AWS again made changes to these steps.

So which one you like, creating bucket using CLI/Code or using S3 console?


We have seen simple ways to create S3 buckets But there is a lot to S3. Versioning, ACL and Policies, Encryption, Static website hosting to name a few. We are going to explore all that in this series of blogs. See you around.

Create S3 bucket

Similar Posts

Leave a Reply

Your email address will not be published.