Update variables.md

This commit is contained in:
David Wells 2017-09-21 16:43:55 -07:00 committed by GitHub
parent 94d8be2c4d
commit 7cf3ec4e2e

View File

@ -20,9 +20,11 @@ They are especially useful when providing secrets for your service to use and wh
To use variables, you will need to reference values enclosed in `${}`.
```
yamlKeyXYZ: ${variableSource}
```yml
# see current variable sources list below
yamlKeyXYZ: ${variableSource}
# this is an example of providing a default value as the second parameter
otherYamlKey: ${variableSource, defaultValue}
```
You can define your own variable syntax (regex) if it conflicts with CloudFormation's syntax
@ -40,6 +42,18 @@ You can define your own variable syntax (regex) if it conflicts with CloudFormat
You can also **Recursively reference properties** with the variable system. This means you can combine multiple values and variable sources for a lot of flexibility.
For example:
```yml
provider:
name: aws
stage: ${opt:stage, 'dev'}
environment:
MY_SECRET: ${file(./config.${self:provider.stage}.json):SECRET}
```
If `--stage dev` is supplied as an option then `${file(./config.${self:provider.stage}.json):SECRET}` is references the `config.dev.json` file
**Note:** You can only use variables in `serverless.yml` property **values**, not property keys. So you can't use variables to generate dynamic logical IDs in the custom resources section for example.
## Reference Properties In serverless.yml