cdk-turnkey / stackname

Print a name for a deployable CDK stack.
Apache License 2.0
0 stars 1 forks source link

Take a region arg, and add a minimal-length region indicator to the suffix #2

Open douglasnaphas opened 3 years ago

douglasnaphas commented 3 years ago

For example, if someone runs

GITHUB_REPOSITORY=douglasnaphas/madliberation GITHUB_REF=refs/heads/master @cdk-turnkey/stackname --suffix xyz --region us-east-1

they should get

DouglasnaphasMadliberationMaster-xyz-ue1

Getting the total list of regions in AWS is not straightforward.

af-south-1
eu-north-1
ap-south-1
eu-west-3
eu-west-2
eu-south-1
eu-west-1
ap-northeast-3
ap-northeast-2
me-south-1
ap-northeast-1
sa-east-1
ca-central-1
ap-east-1
ap-southeast-1
ap-southeast-2
eu-central-1
us-east-1
us-east-2
us-west-1
us-west-2

This document says:

You can't describe or access additional Regions from an AWS account, such as AWS GovCloud (US) Region or the China Regions.

douglasnaphas commented 3 years ago
$ aws --profile=doug ec2 describe-regions --all-regions | jq '.Regions | map(.RegionName)[]' | tr -d '"' | while read r ; do echo -n $r | shasum -a 256 ; done | awk '{print $1}' | sed 's/\(...\).*/\1/' | sort
030
08e
189
295
487
528
5e1
722
7ea
9de
b45
b95
bfe
c35
d02
d2a
d76
d8c
ddc
ea2
fa2
douglasnaphas commented 1 year ago

If someone wanted this, they could just manually incorporate their region into their suffix.