Skip to content

Instantly share code, notes, and snippets.

@chrisj-au
Last active November 27, 2020 00:04
Show Gist options
  • Save chrisj-au/f6ff85e7a6681464cf117821d0542c1c to your computer and use it in GitHub Desktop.
Save chrisj-au/f6ff85e7a6681464cf117821d0542c1c to your computer and use it in GitHub Desktop.
CloudFormation Sub into a string from Map
# Used to provide map values to a long string, e.g. EnvironmentVariables to CodeBuild.
Parameters:
Environment:
Description: Environment to deploy
Type: String
Default: prod
AllowedValues:
- prod
- stage
Mappings:
Environments:
prod:
accountName: aws-prod
tfStateBucket: aws-prod1-terraform-tfstate
stage:
accountName: aws-stage
tfStateBucket: aws-stage-terraform-tfstate
Resources:
Blah:
Properties:
EnvironmentVariables:
!Sub
- |
[{"name":"TF_URL","value": "https://relea..."},
{"name":"tf_statebucket", "value": "${LocalFindInMapBucket}"},
- { LocalFindInMapBucket: !FindInMap [Environments, !Ref Environment, tfStateBucket] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment