From ccb07f6e523bd43fc6ea66a3a24a9360bec0f11a Mon Sep 17 00:00:00 2001 From: Marc Tamsky Date: Tue, 29 Nov 2016 11:59:27 -0800 Subject: [PATCH] Explain list-type variables, and their use --- .../intro/getting-started/variables.html.md | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/website/source/intro/getting-started/variables.html.md b/website/source/intro/getting-started/variables.html.md index 7f7193b27..1a1f022a8 100644 --- a/website/source/intro/getting-started/variables.html.md +++ b/website/source/intro/getting-started/variables.html.md @@ -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. + +## 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" ] +``` + ## Maps