Science & Space

How to Create and Manage Amazon S3 Buckets with Account Regional Namespaces

2026-05-01 15:04:25

Introduction

Amazon Simple Storage Service (Amazon S3) now offers account regional namespaces for general purpose buckets. This feature allows you to create buckets with predictable names that are unique to your AWS account and region, simplifying bucket management as your storage needs grow. By appending a unique suffix (your AWS account ID, region, and '-an') to your chosen bucket name, you ensure that no other account can claim the same bucket name in that region. This guide walks you through the prerequisites and step-by-step process to enable and use account regional namespaces via the AWS Management Console, AWS CLI, and AWS SDK for Python (Boto3).

How to Create and Manage Amazon S3 Buckets with Account Regional Namespaces
Source: aws.amazon.com

What You Need

Step-by-Step Guide

Step 1: Understand the Account Regional Suffix

When you create a bucket in your account regional namespace, the full bucket name consists of a prefix you choose (e.g., mybucket) and an account regional suffix that AWS adds automatically. The suffix follows this format: -{AWS account ID}-{region}-an. For example, if your AWS account ID is 123456789012, region is us-east-1, and your chosen prefix is mybucket, the resulting bucket name is mybucket-123456789012-us-east-1-an. The combined length must be between 3 and 63 characters.

Step 2: Create a Bucket Using the AWS Management Console

  1. Sign in to the Amazon S3 console.
  2. Click Create bucket.
  3. Under Bucket naming, you will see two options: Global namespace (default) and Account regional namespace.
  4. Select Account regional namespace.
  5. In the Bucket name field, enter your desired prefix (e.g., mybucket). The console will automatically append your account regional suffix and show the final bucket name.
  6. Configure any additional settings (e.g., versioning, encryption, permissions) as needed. Note that all features available for global namespace buckets are also supported here.
  7. Click Create bucket.

Step 3: (Optional) Enforce Account Regional Namespace Usage with IAM Policies

Your security team can enforce that users only create buckets in their account regional namespace. Use the new condition key s3:x-amz-bucket-namespace in IAM policies or AWS Organizations service control policies. An example IAM policy statement to allow only account-regional bucket creation:

{
  "Effect": "Allow",
  "Action": "s3:CreateBucket",
  "Resource": "arn:aws:s3:::*",
  "Condition": {
    "StringEquals": {
      "s3:x-amz-bucket-namespace": "account-regional"
    }
  }
}

Step 4: Create a Bucket Using AWS CLI

  1. Ensure your AWS CLI is configured with appropriate credentials (aws configure).
  2. Use the create-bucket command with the --bucket-namespace parameter set to account-regional. The bucket name must already include the correct suffix. Example:
    aws s3api create-bucket \
      --bucket mybucket-123456789012-us-east-1-an \
      --bucket-namespace account-regional \
      --region us-east-1
  3. Verify the bucket was created by running aws s3 ls or aws s3api list-buckets.

Step 5: Create a Bucket Using AWS SDK for Python (Boto3)

  1. Install and configure Boto3 (pip install boto3).
  2. Use the following Python code to create a bucket in your account regional namespace. The script uses STS to retrieve your account ID and region.
import boto3
from botocore.config import Config

# Initialize clients
session = boto3.Session()
sts = session.client('sts')
s3 = session.client('s3', config=Config(region_name='us-east-1'))

# Get account details
identity = sts.get_caller_identity()
account_id = identity['Account']
region = session.region_name

# Define prefix and suffix
prefix = 'mybucket'
suffix = f"-{account_id}-{region}-an"
bucket_name = prefix + suffix

# Create bucket
response = s3.create_bucket(
    Bucket=bucket_name,
    CreateBucketConfiguration={'LocationConstraint': region},
    BucketNamespace='account-regional'  # Boto3 supports this parameter
)
print(f"Bucket created: {bucket_name}")

Note: In the CreateBucket API call, include the BucketNamespace parameter with value 'account-regional'.

How to Create and Manage Amazon S3 Buckets with Account Regional Namespaces
Source: aws.amazon.com

Tips and Best Practices

By following these steps, you can confidently create Amazon S3 buckets within your own account regional namespace, ensuring unique bucket names across regions and simplifying governance.

Explore

Crypto Market Update: Monero Soars, Regulatory Shifts, and Industry Moves – Key Questions Answered Democrats Unveil Bold Blueprint to Rein in Health Care Costs Across the Board Non-Deterministic Code from LLM Agents Forces Rethink of Software Testing, Says SmartBear VP How Beginner Guide to CJ Affiliate (Commission Junction) in 2022 Unearthing Ancient Trade: How Spanish Bronze Age Mines Solved a Scandinavian Metal Mystery