Skip to main content

s3-unique-bucket

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.

Example

bucket=$(s3-unique-bucket)
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.

Documentation

Set the AWS credentials and region with environment variables.

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_DEFAULT_REGION

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.

Metadata

Release files for s3-unique-bucket 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for s3-unique-bucket 0.1.0
File Size Uploaded Provenance Actions
s3_unique_bucket-0.1.0.tar.gz 3.0 kB Without provenance Details for s3_unique_bucket-0.1.0.tar.gz

Release files / s3_unique_bucket-0.1.0.tar.gz

Download URL s3_unique_bucket-0.1.0.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
82f3d4aa206f77cfca79a3bf2a87e5ad54dbe7e91c881f2302d39e2075e11df9
BLAKE2b-256 checksum
How to use checksums
abd41723bbe4564444b5555b63fe9f4365e79045246be36fdc9e52c0237b65f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

Security for s3-unique-bucket 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page