Creating AWS S3 Buckets (AWS)

EC2 Amazon Linux AMI Banner

Today I am going to look at the storage solution that is AWS S3 (Simple Storage Service), and creating buckets via the web management console and the AWS CLI.

Note: This post forms part of my (slightly new) AWS category of posts.

What is AWS S3?

AWS Simple Storage Service (S3) is a place to store files, which can be kept private or shared out. It can also be used as to serve static content (i.e. static webpages and their content), especially when tied into AWS’ Route 53 service.

What are buckets?

Buckets are storage containers to hold the files. A bucket must be created before any files are stored in AWS S3. Their are some “restrictions” on buckets:

  • The bucket is owned by the account that created it
  • Each account can have 100 buckets, after that AWS needs to be contacted if additional buckets are required
  • Bucket names must be unique
  • Bucket names must be DNS compliant
  • Bucket names must be at least 3 characters long and no more than 63 characters
  • After you create a bucket you cannot change the region it is stored in
  • Buckets cannot be stored within buckets

There is no limit on the amount of items a bucket can hold, and the number of items in a bucket does not affect the buckets performance.

Creating a bucket (AWS Web Management Console)

To create an S3 bucket via the AWS Management Console.

Open the AWS Management Console and log in, clicking “Services” in the top left of the screen to open the services menu. Select “S3” from under the “Storage” option.

AWS Management Console
AWS Management Console

The “S3 buckets” screen will now show. If your account already has buckets in use then they will show here. To create a bucket, click “Create bucket”.

geektechstuff_aws_s3_bucket_w2
AWS S3 bucket screen

The “create bucket” wizard will launch and walk you through the four required steps.

Step 1 asks for a unique bucket name (see my bit on restrictions above) and which region the bucket should be saved in. I’ve gone with EU (London) as that is close for me. If you have previous buckets then you can copy the settings from one of them to save time.

geektechstuff_aws_s3_bucket_w3
Creating an AWS S3 bucket step 1

Step 2 has options for versioning (allowing for versions to be stored in different buckets), logging (allowing to log any and all requests for access to the bucket) and tagging. I’ve wrote a few times about the need for tagging and I’ll write again, make sure you tag the resource appropriately.

Creating an AWS S3 bucket step 2
Creating an AWS S3 bucket step 2

Step 3 looks at the access settings for the bucket. If the bucket is for private use and does not require anyone else to access it then I recommend the default option of block all public access. I’m hoping to tackle ACLs (Access Control Lists) in the future, but if you want to read up on them now then check out https://docs.aws.amazon.com/AmazonS3/latest/user-guide/set-bucket-permissions.html

geektechstuff_aws_s3_bucket_w5
Creating an AWS S3 bucket step 3

Step 4 confirms the choices made during the previous screens. Pressing “Create bucket” finalises it and creates the bucket.

geektechstuff_aws_s3_bucket_w6
Creating an AWS S3 bucket step 4

Once created, the bucket will show in the S3 buckets screen.

AWS S3 Bucket Screen
AWS S3 Bucket Screen

The S3 bucket can be deleted or the public access settings changed via this screen.

Creating a bucket (AWS CLI)

My preferred method of interacting with AWS is via the AWS CLI.

Creating a similar bucket to the above via AWS CLI can be done with the following command:

aws s3api create-bucket –bucket geektechstuffbucket2  –region eu-west-2 –create-bucket-configuration LocationConstraint=eu-west-2 –acl private

geektechstuff_aws_s3_bucket_w8
AWS CLI to create an S3 bucket

Where geektechstuffbucket2 is my buckets name, i.e. replace this with the name you want to give your bucket.

–region and –create-bucket-configuration Location Constraint are both needed when creating buckets in certain areas. –acl sets the acl (security) settings, options for this include:

  • private
  • public-read
  • public-read-write
  • authenticated-read

Note: private means the bucket is private, the content could still be public.

Buckets Have Addresses

As bucket names are unique they can be used as web addresses, for example the bucket in my AWS CLI example has an address of: http://geektechstuffbucket2.s3.amazonaws.com/ .

Using AWS CLI to list buckets

The AWS CLI can be used to quickly list the buckets within your AWS account using the command:

aws s3 ls

geektechstuff_aws_s3_bucket_w9
aws s3 ls

Deleting empty S3 buckets via AWS CLI

As long as the bucket is empty (i.e. it contains no data) it can be deleted using the command:

aws s3api delete-bucket –bucket geektechstuffbucket2

geektechstuff_aws_s3_bucket_w10
aws s3api delete-bucket –bucket geektechstuffbucket2
Posted in AWS

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.