Skip to main content

Insures a unique S3 bucket exists for the account

Project description


Utility to create a unique bucket for each S3 account, useful for deployment scenarios.

Did you ever need a bucket to upload your deployment templates into? Are you always annoyed by having to create them manually, not really making your deployment pipeline truly automatic? Well, worry no more!

This script is an easy and idempotent way to just create an S3 bucket that will have a very high chance to avoid name conflicts. If run a second time, the script recognizes the bucket already exists and will only emit the bucket's name for reuse.


aws s3 cp foo.txt s3://$bucket/foo.txt

How it works

The bucket name is generated from a user-settable prefix, the sha1 hash of the account ID with base32 encoding, and the region the bucket is created in. Then the script checks if a bucket with this name exists on the provided account. If not, it is created. Then finally the name of the bucket is emitted via stdout.


Set the AWS credentials and region with environment variables.


The rest is configured with command line arguments.

-p/--prefix: User-settable prefix (OPTIONAL)

Default: account-bucket

The bucket name starts with this settable prefix. It can also be empty. Note that a dash ('-') is automatically added between the prefix and the hash if prefix is not empty.

-p/--prefix: AWS Account Region (CONDITIONAL)

Condition: Must be provided if environment variable AWS_DEFAULT_REGION isn't set.

Which region the bucket shall be created in.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

s3_unique_bucket-0.1.0.tar.gz (3.0 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page