Create S3 bucket using AWS CLI Command mb


Create S3 bucket using AWS CLI Command mb

In order to create an S3 bucket using AWS CLI you can make use of the aws s3 mb command followed by the name of the bucket as S3Uri

Example:
% aws s3 mb s3://my-bucket-unique-bucket-name
make_bucket: my-bucket-unique-bucket-name

If the bucket is created you would see make_bucket as a response followed by the bucket name.

As bucket names are shared namespace, it is possible that the bucket that you are trying to create already exists, in such a case you will get an error like the below,

% aws s3 mb s3://my-bucket
        
make_bucket failed: s3://my-bucket An error occurred (BucketAlreadyExists) 
when calling the CreateBucket operation: 
The requested bucket name is not available. 
The bucket namespace is shared by all users of the system. 
Please select a different name and try again.
Question: How to create a bucket in a specific region?

In order to create a bucket in a specific region you can make use of the --region parameter followed by the region name,

Example:
% aws s3 mb s3://my-bucket-unique-bucket-name --region us-west-2
List of all regions:
af-south-1
eu-north-1
ap-south-1
eu-west-3
eu-west-2
eu-south-1
eu-west-1
ap-northeast-3
ap-northeast-2
me-south-1
ap-northeast-1
sa-east-1
ca-central-1
ap-east-1
ap-southeast-1
ap-southeast-2
ap-southeast-3
eu-central-1
us-east-1
us-east-2
us-west-1
us-west-2


















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap