Create an S3 bucket in a specific AWS region using CLI Command


S3 buckets are default created in the region that is set in the AWS configure profile, if you want to create an S3 bucket in a specific region you can make use of the option --region followed by the region name.



Example: Create a bucket in us-east-1 region
% aws s3 mb s3:\\my-unique-bucket-name --region us-west-1


Example: Create a bucket in eu-west-1 region
% aws s3 mb s3:\\my-unique-bucket-name --region eu-west-1


As you can see in the below example, I have the default region set to us-west-1, when I create a new s3 bucket in us-east-1 region, I can do an ls with --region us-east-1 to see all the buckets in that specific region

% aws configure get region
us-west-1

% aws s3 mb s3:\\c2c-bucket-1 --region us-east-1
make_bucket: c2c-bucket-1

% aws s3 ls --region us-east-1
2022-08-16 23:48:37 c2c-bucket-1


Create S3 bucket in specific region

If you do not have permission to create buckets in a specific region you will get AccessDenied on CreateBucket and ListBuckets operations.

% aws s3 mb s3://c2c-bucket-2 --region us-east-2
make_bucket failed: s3://c2c-bucket-2 An error occurred (AccessDenied) when 
calling the CreateBucket operation: Access Denied

Top Hashtags:

Advertisements

Advertisements




Advertisements