Last active
June 24, 2020 03:22
-
-
Save jsonw23/e8c9265ca5d93ebeff8e4a9bd549b95d to your computer and use it in GitHub Desktop.
Environment variable mapping based on DeploymentStage parameter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Mappings: | |
| EnvironmentVariables: | |
| # mapping keys are the allowed values for DeploymentStage | |
| staging: | |
| # mapping value is multi-value where key is the environment variable | |
| PROD: false | |
| API_URL: {staging api endpoint url} | |
| production: | |
| PROD: true | |
| API_URL: {production api endpoint url} | |
| Resources: | |
| HelloWorldFunction: | |
| # ... | |
| Environment: | |
| Variables: | |
| STAGE: !Ref DeploymentStage | |
| # instrinsic FindInMap function looks up the value by the deployment stage and the env var name | |
| PROD: !FindInMap [EnvironmentVariables, !Ref DeploymentStage, PROD] | |
| API_URL: !FindInMap [EnvironmentVariables, !Ref DeploymentStage, API_URL] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment