LinuxCommandLibrary

aws-s3-mb

Create Amazon S3 buckets

TLDR

Create an S3 bucket

$ aws s3 mb s3://[bucket_name]
copy

Create an S3 bucket in a specific region
$ aws s3 mb s3://[bucket_name] --region [region]
copy

Display help
$ aws s3 mb help
copy

SYNOPSIS

aws s3 mb s3://BUCKET [s3://BUCKET ...] [--region REGION] [--create-bucket-configuration value]

PARAMETERS

s3://BUCKET
    Positional argument: S3 URI of bucket(s) to create (supports multiple)

--region
    AWS region (e.g., us-west-2) where bucket is created; auto-sets LocationConstraint if needed

--create-bucket-configuration
    JSON structure for bucket config, e.g., file://config.json with {"LocationConstraint":"region"}

DESCRIPTION

The aws s3 mb command, part of the AWS Command Line Interface (CLI), creates one or more Amazon Simple Storage Service (S3) buckets. S3 buckets serve as containers for objects (files) and can store virtually unlimited data.

Key requirements: Bucket names must be globally unique across all AWS accounts, 3-63 characters long, DNS-compliant (lowercase letters, numbers, hyphens, periods; no consecutive periods or hyphens at start/end). You need IAM permissions like s3:CreateBucket.

Basic usage creates a bucket in your default AWS region (often us-east-1): aws s3 mb s3://my-unique-bucket. Specify multiple buckets by listing URIs: aws s3 mb s3://bucket1 s3://bucket2.

For other regions, use --region; the CLI automatically sets the location constraint for non-us-east-1 regions. Alternatively, provide a JSON config via --create-bucket-configuration for explicit control, e.g., {"LocationConstraint":"us-west-2"}.

Success outputs the bucket ARN. Failures include name conflicts or permission issues. Integrates with AWS profiles for authentication.

CAVEATS

Bucket names are globally unique; existing names fail. Non-us-east-1 regions require LocationConstraint (auto via --region). No versioning/encryption flags here—use post-creation commands. Rate limits apply (~3 creates/sec/account).

EXAMPLE

aws s3 mb s3://my-test-bucket --region eu-west-1
Creates bucket in eu-west-1.

CONFIG JSON

config.json: {"LocationConstraint": "ap-southeast-2"}
aws s3 mb s3://bucket --create-bucket-configuration file://config.json

HISTORY

Introduced in AWS CLI v1 (2013) as high-level S3 command; enhanced in v2 (2020) for better UX and multi-bucket support.

SEE ALSO

aws s3 rb(1), aws s3 ls(1), aws s3api create-bucket(1)

Copied to clipboard