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-name [--region value] [--endpoint-url value] [options]

PARAMETERS

s3://bucket-name
    The Amazon S3 URI specifying the name of the bucket to create. This name must be globally unique and adhere to S3 naming conventions.

--region value
    Specifies the AWS region where the S3 bucket should be created (e.g., us-east-1). If not specified, the default region configured for the AWS CLI is used.

--endpoint-url value
    Overrides the default S3 service endpoint for the specified region. Useful for connecting to S3-compatible services or private endpoints.

--no-verify-ssl
    Disables SSL certificate verification. Use with caution, as it can expose you to security risks when connecting to non-trusted endpoints.

DESCRIPTION

The aws s3 mb command is a core utility within the AWS Command Line Interface (CLI) for provisioning new storage buckets in Amazon S3. It allows users to programmatically create an S3 bucket with a specified name in a particular AWS Region. Each S3 bucket name must be globally unique across all AWS accounts, and it must adhere to specific DNS-compliant naming conventions (e.g., all lowercase, no underscores, between 3 and 63 characters long).

While the request specifically mentioned aws-s3-mb, the standard and widely adopted command for this operation in the AWS CLI is aws s3 mb. It is highly probable that aws-s3-mb refers to a custom script or an alias wrapping the official aws s3 mb command. This analysis focuses on the standard aws s3 mb behavior.

Successful execution of this command requires the AWS CLI to be installed and configured with appropriate IAM credentials that possess the s3:CreateBucket permission.

CAVEATS

Bucket names must be globally unique across all AWS accounts. If the chosen name is already taken, the command will fail.
Bucket naming conventions are strict; refer to AWS documentation for full details.
Creating a bucket incurs storage costs once objects are stored. Ensure you understand S3 pricing.
Permissions are crucial: the IAM user or role executing this command must have the s3:CreateBucket permission.
While the bucket is created, its security settings (e.g., public access blocks, default encryption) should be reviewed and configured post-creation to align with security best practices.

BUCKET NAMING CONVENTIONS

S3 bucket names must be globally unique and follow strict DNS-compliant rules:
- Must be between 3 and 63 characters long.
- Can consist only of lowercase letters, numbers, and hyphens (-).
- Must begin and end with a letter or number.
- Cannot contain underscores, periods (.), or be formatted as an IP address.
- Cannot start with xn--.

IAM PERMISSIONS

To successfully create an S3 bucket, the AWS credentials used by the AWS CLI must have the s3:CreateBucket permission granted by an IAM policy attached to the executing user or role.

REGION SPECIFICITY

While S3 is a global service from a namespace perspective, buckets are created in specific AWS Regions. Data stored in a bucket never leaves its region unless explicitly transferred. Choosing the right region is important for latency, compliance, and cost optimization, as well as for data residency requirements.

HISTORY

The AWS Command Line Interface (CLI), of which aws s3 mb is a part, was first publicly released in 2013. It was developed by Amazon Web Services to provide a unified, consistent, and powerful tool for interacting with various AWS services from the command line. Prior to the AWS CLI, users often relied on individual service-specific tools or SDKs. The `s3` subcommand group, including `mb` for 'make bucket', `rb` for 'remove bucket', `cp` for 'copy', and `ls` for 'list', has been a fundamental part of the S3 functionality within the CLI since its early versions, evolving alongside the S3 service itself.

SEE ALSO

aws(1), aws s3 rb(1), aws s3 ls(1), aws s3 cp(1), s3cmd(1)

Copied to clipboard