github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration-0-11/environment-variables.html.md (about) 1 --- 2 layout: "docs" 3 page_title: "Environment Variables - 0.11 Configuration Language" 4 sidebar_current: "docs-conf-old-environment-variables" 5 description: |- 6 Terraform uses different environment variables that can be used to configure various aspects of how Terraform behaves. this section documents those variables, their potential values, and how to use them. 7 --- 8 9 # Environment Variables 10 11 -> **Note:** This page is about Terraform 0.11 and earlier. For Terraform 0.12 12 and later, see 13 [Commands: Environment Variables](../commands/environment-variables.html). 14 15 ## TF_LOG 16 17 If set to any value, enables detailed logs to appear on stderr which is useful for debugging. For example: 18 19 ```shell 20 export TF_LOG=TRACE 21 ``` 22 23 To disable, either unset it or set it to empty. When unset, logging will default to stderr. For example: 24 25 ```shell 26 export TF_LOG= 27 ``` 28 29 For more on debugging Terraform, check out the section on [Debugging](/docs/internals/debugging.html). 30 31 ## TF_LOG_PATH 32 33 This specifies where the log should persist its output to. Note that even when `TF_LOG_PATH` is set, `TF_LOG` must be set in order for any logging to be enabled. For example, to always write the log to the directory you're currently running terraform from: 34 35 ```shell 36 export TF_LOG_PATH=./terraform.log 37 ``` 38 39 For more on debugging Terraform, check out the section on [Debugging](/docs/internals/debugging.html). 40 41 ## TF_INPUT 42 43 If set to "false" or "0", causes terraform commands to behave as if the `-input=false` flag was specified. This is used when you want to disable prompts for variables that haven't had their values specified. For example: 44 45 ```shell 46 export TF_INPUT=0 47 ``` 48 49 ## TF_MODULE_DEPTH 50 51 When given a value, causes terraform commands to behave as if the `-module-depth=VALUE` flag was specified. By setting this to 0, for example, you enable commands such as [plan](/docs/commands/plan.html) and [graph](/docs/commands/graph.html) to display more compressed information. 52 53 ```shell 54 export TF_MODULE_DEPTH=0 55 ``` 56 57 For more information regarding modules, see [Configuration Language: Modules](/docs/configuration/modules.html). 58 59 ## TF_VAR_name 60 61 Environment variables can be used to set variables. The environment variables must be in the format `TF_VAR_name` and this will be checked last for a value. For example: 62 63 ```shell 64 export TF_VAR_region=us-west-1 65 export TF_VAR_ami=ami-049d8641 66 export TF_VAR_alist='[1,2,3]' 67 export TF_VAR_amap='{ foo = "bar", baz = "qux" }' 68 ``` 69 70 For more on how to use `TF_VAR_name` in context, check out the section on [Variable Configuration](./variables.html). 71 72 ## TF_CLI_ARGS and TF_CLI_ARGS_name 73 74 The value of `TF_CLI_ARGS` will specify additional arguments to the 75 command-line. This allows easier automation in CI environments as well as 76 modifying default behavior of Terraform on your own system. 77 78 These arguments are inserted directly _after_ the subcommand 79 (such as `plan`) and _before_ any flags specified directly on the command-line. 80 This behavior ensures that flags on the command-line take precedence over 81 environment variables. 82 83 For example, the following command: `TF_CLI_ARGS="-input=false" terraform apply -force` 84 is the equivalent to manually typing: `terraform apply -input=false -force`. 85 86 The flag `TF_CLI_ARGS` affects all Terraform commands. If you specify a 87 named command in the form of `TF_CLI_ARGS_name` then it will only affect 88 that command. As an example, to specify that only plans never refresh, 89 you can set `TF_CLI_ARGS_plan="-refresh=false"`. 90 91 The value of the flag is parsed as if you typed it directly to the shell. 92 Double and single quotes are allowed to capture strings and arguments will 93 be separated by spaces otherwise. 94 95 ## TF_DATA_DIR 96 97 `TF_DATA_DIR` changes the location where Terraform keeps its 98 per-working-directory data, such as the current remote backend configuration. 99 100 By default this data is written into a `.terraform` subdirectory of the 101 current directory, but the path given in `TF_DATA_DIR` will be used instead 102 if non-empty. 103 104 In most cases it should not be necessary to set this variable, but it may 105 be useful to do so if e.g. the working directory is not writable. 106 107 The data directory is used to retain data that must persist from one command 108 to the next, so it's important to have this variable set consistently throughout 109 all of the Terraform workflow commands (starting with `terraform init`) or else 110 Terraform may be unable to find providers, modules, and other artifacts. 111 112 ## TF_SKIP_REMOTE_TESTS 113 114 This can be set prior to running the unit tests to opt-out of any tests 115 requiring remote network connectivity. The unit tests make an attempt to 116 automatically detect when connectivity is unavailable and skip the relevant 117 tests, but by setting this variable you can force these tests to be skipped. 118 119 ```shell 120 export TF_SKIP_REMOTE_TESTS=1 121 make test 122 ```