Difference Between aws s3 mb and aws s3api create-bucket:
aws s3 mb
:This command is specifically designed to create new S3 buckets.
It is a higher-level, simplified command that automatically handles the bucket creation process.
However, it only works with buckets in the
us-east-1
region without the need for specifying aLocationConstraint
in the command.
Example:
aws s3 mb s3://<bucket-name> --region <region-name>
This command would work perfectly for creating a bucket in us-east-1
without needing extra options.
aws s3api create-bucket
:This is a lower-level command that gives you more control over the creation process, allowing you to specify additional options like a custom bucket policy, versioning, or the
LocationConstraint
for regions other thanus-east-1
.It's more flexible and used when you need to create buckets in regions outside
us-east-1
, or when you need to configure more advanced settings during bucket creation.
Example for us-east-1
:
aws s3api create-bucket --bucket <bucket-name> --region <region-name> --create-bucket-configuration LocationConstraint=<region-name>
Summary:
If you're creating a bucket in us-east-1, using
aws s3 mb
is a simpler option and would work fine.If you need more control over the bucket creation or are working in other regions,
aws s3api create-bucket
is better because it provides additional configuration options.