Create an AWS S3 Bucket using AWS CLI

Vishal Sharma
3 min readNov 12, 2019

--

Creating an AWS S3 (Simple Storage Service) Bucket using AWS CLI (Command Line Interface) is very easy and we can S3 Bucket using few AWS CLI commands.

Prerequisite: AWS CLI should be installed on the system. Please see how can we install AWS CLI on Ubuntu Machine. We can also install AWS CLI on Ubuntu machine using the following commands:

sudo apt udpate
sudo apt install awscli

We need to check the AWS CLI version using the following command.

aws --version

Now we need to configure the AWS CLI with the following command. We need AWS Access Key ID, AWS Secret Access Key to configure the same.

aws configure

Now, we have configured AWS on our system. We can start using the AWS CLI. Use ‘aws’ command to get started. For example, using S3 commands, we can use ‘aws s3 help’

aws
aws s3 help
aws s3 ls

We can use s3api to create a bucket using AWS CLI

aws s3api helpDESCRIPTION
AVAILABLE COMMANDS
o abort-multipart-upload
o complete-multipart-uploado copy-objecto create-bucketo create-multipart-uploado delete-bucketo delete-bucket-analytics-configurationo delete-bucket-corso delete-bucket-encryptiono delete-bucket-inventory-configurationo delete-bucket-lifecycleo delete-bucket-metrics-configurationo delete-bucket-policyo delete-bucket-replicationo delete-bucket-taggingo delete-bucket-websiteo delete-objecto delete-object-taggingo delete-objectso get-bucket-accelerate-configurationo get-bucket-aclo get-bucket-analytics-configurationo get-bucket-corso get-bucket-encryptiono get-bucket-inventory-configurationo get-bucket-lifecycle-configurationo get-bucket-locationo get-bucket-loggingo get-bucket-metrics-configurationo get-bucket-notification-configurationo get-bucket-policyo get-bucket-replicationo get-bucket-request-paymento get-bucket-taggingo get-bucket-versioningo get-bucket-websiteo get-objecto get-object-aclo get-object-taggingo get-object-torrento head-bucketo head-objecto helpo list-bucket-analytics-configurationso list-bucket-inventory-configurationso list-bucket-metrics-configurationso list-bucketso list-multipart-uploadso list-object-versionso list-objectso list-objects-v2o list-partso put-bucket-accelerate-configurationo put-bucket-aclo put-bucket-analytics-configurationo put-bucket-corso put-bucket-encryptiono put-bucket-inventory-configurationo put-bucket-lifecycle-configurationo put-bucket-loggingo put-bucket-metrics-configurationo put-bucket-notification-configurationo put-bucket-policyo put-bucket-replicationo put-bucket-request-paymento put-bucket-taggingo put-bucket-versioningo put-bucket-websiteo put-objecto put-object-aclo put-object-taggingo restore-objecto upload-parto upload-part-copyo wait

Run the following command to create a sample bucket on us-east-1 region.

aws s3api create-bucket --bucket test-bucket-989282 --region us-east-1

The output will be like:

“Location”: /test-bucket-989282 (The bucket name provided)

We can also perform several operations like list, get, put, delete objects and buckets depending upon our requirements.

--

--

Vishal Sharma

IT Enthusiast, Professional, Novice Sportsperson and Fantasist of Better World. @byVishalSharma on Twitter.