Merge pull request #10421 from tamsky/patch-1

Explain list-type variables, and their use
This commit is contained in:
Mitchell Hashimoto 2016-12-01 18:09:14 -05:00 committed by GitHub
commit 3b0ae1a77b
1 changed files with 21 additions and 1 deletions

View File

@ -56,7 +56,8 @@ the AWS provider with the given variables.
## Assigning Variables
There are multiple ways to assign variables. Below is also the order
in which variable values are chosen. The following is the descending order of precedence in which variables are considered.
in which variable values are chosen. The following is the descending order
of precedence in which variables are considered.
#### Command-line flags
@ -109,6 +110,8 @@ $ terraform plan \
-var-file="secret.tfvars" \
-var-file="production.tfvars"
```
-> **Note**: Environment variables can only populate string-type variables.
List and map type variables must be populated via one of the other mechanisms.
#### UI Input
@ -126,6 +129,23 @@ If no value is assigned to a variable via any of these methods and the
variable has a `default` key in its declaration, that value will be used
for the variable.
<a id="lists"></a>
## Lists
Lists are defined either explicitly or implicity
```
# implicitly by using brackets [...]
variable "cidrs" { default = [] }
# explicitly
variable "cidrs" { type = "list" }
```
You can specify lists in a `terraform.tfvars` file:
```
cidrs = [ "10.0.0.0/16", "10.1.0.0/16" ]
```
<a id="mappings"></a>
<a id="maps"></a>
## Maps