Difference Between aws s3 mb and aws s3api create-bucket:

·

1 min read

  1. 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 a LocationConstraint 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.

  1. 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 than us-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.