Skip to content

Append account number to S3 bucket names #6860

@patchwork01

Description

@patchwork01

User Story

As a user deploying Sleeper, I want Sleeper's AWS resource names to not conflict with other accounts, so that my choice of instance ID will not conflict with other instances in other accounts.

Description / Background

S3 bucket names are globally unique, and a maximum of 63 characters long. This is one of the main restrictions on the length of the Sleeper instance ID, which we've set to a maximum of 20 characters.

We'd like to append the account number to all S3 bucket names deployed in a Sleeper instance, to avoid conflicts with similarly named Sleeper instances.

Technical Notes / Implementation Details

This will be for every S3 bucket deployed in the cdk and system-test-cdk modules.

Taking a long bucket name as an example:

sleeper-<instance-id>-bulk-export-results

If you append the account name and region you get something like this:

sleeper-<instance-id>-bulk-export-results-123456789012-eu-west-2

With a 20 character instance ID that comes to 72 characters.

More generally, buckets would be named in this form:

sleeper-<instance-id>-<name>-<account>-<region>

The "sleeper" and hyphens come to 11 characters.

The account name is exactly 12 digits long.

The longest region names are 14 characters long.

Overall, that leaves 63 - 20 - 11 - 12 - 14 = 6 characters for a name specific to the bucket.

We'll need to make sure that name portion is 6 characters or less for every bucket we deploy.

We can leave the region out of the name and just include the account number, which would take off -<region>, giving us 6 + 14 + 1 = 21 characters for the name portion. That seems worth doing, as it's unlikely you'll want to use the same instance ID in multiple regions.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions