From d12b6376025e23aa4d4216a25712e902afd0afc7 Mon Sep 17 00:00:00 2001 From: James Nugent Date: Mon, 17 Oct 2016 11:39:12 -0500 Subject: [PATCH] docs: Clarify terraform.tfvars file additions --- .../docs/configuration/variables.html.md | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/website/source/docs/configuration/variables.html.md b/website/source/docs/configuration/variables.html.md index 8f0167a6a..5fe192472 100644 --- a/website/source/docs/configuration/variables.html.md +++ b/website/source/docs/configuration/variables.html.md @@ -197,13 +197,14 @@ $ TF_VAR_somemap='{foo = "bar", baz = "qux"}' terraform plan Variables can be collected in files and passed all at once using the `-var-file=foo.tfvars` flag. -If a "terraform.tfvars" file is present in the current directory, Terraform -automatically loads it to populate variables. If the file is named something -else, you can use the -var-file flag directly to specify a file. These files -are the same syntax as Terraform configuration files. And like Terraform -configuration files, these files can also be JSON. The format for variables in -`.tfvars` files is [HCL](/docs/configuration/syntax.html#HCL), with top level -key/value pairs: +If a file named `terraform.tfvars` is present in the current directory, +Terraform automatically loads it to populate variables. If the file is named +something else, you can pass the path to the file using the the `-var-file` +flag. + +Variables files use HCL or JSON to define variable values. Strings, lists or +maps may be set in the same manner as the default value in a `variable` block +in Terraform configuration. For example: ``` foo = "bar" @@ -224,9 +225,9 @@ The flag can be used multiple times per command invocation: terraform apply -var-file=foo.tfvars -var-file=bar.tfvars ``` -**Note** If a variable is defined in more than one file passed, the last -variable file (reading left to right) will be the definition used. Put more -simply, the last time a variable is defined is the one which will be used. +**Note** Variable files are evaluated in the order in which they are specified +on the command line. If a variable is defined in more than one variables file, +the last value specified is effective. ### Precedence example: