From 016f37244e9a37a951f7efa11b490e0671c1c13a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Gustafson?= Date: Fri, 29 Apr 2016 12:26:06 +0200 Subject: [PATCH] Tweak docs to properly document .tfvars format As reported and described in hashicorp/terraform#3292 --- .../docs/configuration/variables.html.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/website/source/docs/configuration/variables.html.md b/website/source/docs/configuration/variables.html.md index 1062b32bb38b..ea454c1dcbc9 100644 --- a/website/source/docs/configuration/variables.html.md +++ b/website/source/docs/configuration/variables.html.md @@ -153,7 +153,13 @@ $ TF_VAR_image=foo terraform apply ## Variable Files Variables can be collected in files and passed all at once using the -`-var-file=foo` flag. +`-var-file=foo.tfvars` flag. The format for variables in `.tfvars` +files is: +``` +foo = "bar" +xyz = "abc" + +``` The flag can be used multiple times per command invocation: @@ -165,22 +171,18 @@ terraform apply -var-file=foo.tfvars -var-file=bar.tfvars 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. -##Example: +### Precedence example: Both these files have the variable `baz` defined: _foo.tfvars_ ``` -variable "baz" { - default = "foo" -} +baz = "foo" ``` _bar.tfvars_ ``` -variable "baz" { - default = "bar" -} +baz = "bar" ``` When they are passed in the following order: