Movatterモバイル変換


[0]ホーム

URL:


HashiConf 2025Don't miss the live stream of HashiConf Day 2 happening now View live stream

You are viewing documentation for version v1.1.x.View latest version.

Terraform refers to a number of environment variables to customize variousaspects of its behavior. None of these environment variables are requiredwhen using Terraform, but they can be used to change some of Terraform'sdefault behaviors in unusual situations, or to increase output verbosityfor debugging.

TF_LOG

Enables detailed logs to appear on stderr which is useful for debugging. For example:

export TF_LOG=trace

To disable, either unset it, or set it tooff. For example:

export TF_LOG=off

For more on debugging Terraform, check out the section onDebugging.

TF_LOG_PATH

This specifies where the log should persist its output to. Note that even whenTF_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:

export TF_LOG_PATH=./terraform.log

For more on debugging Terraform, check out the section onDebugging.

TF_INPUT

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:

export TF_INPUT=0

TF_VAR_name

Environment variables can be used to set variables. The environment variables must be in the formatTF_VAR_name and this will be checked last for a value. For example:

export TF_VAR_region=us-west-1export TF_VAR_ami=ami-049d8641export TF_VAR_alist='[1,2,3]'export TF_VAR_amap='{ foo = "bar", baz = "qux" }'

For more on how to useTF_VAR_name in context, check out the section onVariable Configuration.

TF_CLI_ARGS and TF_CLI_ARGS_name

The value ofTF_CLI_ARGS will specify additional arguments to thecommand-line. This allows easier automation in CI environments as well asmodifying default behavior of Terraform on your own system.

These arguments are inserted directlyafter the subcommand(such asplan) andbefore any flags specified directly on the command-line.This behavior ensures that flags on the command-line take precedence overenvironment variables.

For example, the following command:TF_CLI_ARGS="-input=false" terraform apply -forceis the equivalent to manually typing:terraform apply -input=false -force.

The flagTF_CLI_ARGS affects all Terraform commands. If you specify anamed command in the form ofTF_CLI_ARGS_name then it will only affectthat command. As an example, to specify that only plans never refresh,you can setTF_CLI_ARGS_plan="-refresh=false".

The value of the flag is parsed as if you typed it directly to the shell.Double and single quotes are allowed to capture strings and arguments willbe separated by spaces otherwise.

TF_DATA_DIR

TF_DATA_DIR changes the location where Terraform keeps itsper-working-directory data, such as the current backend configuration.

By default this data is written into a.terraform subdirectory of thecurrent directory, but the path given inTF_DATA_DIR will be used insteadif non-empty.

In most cases it should not be necessary to set this variable, but it maybe useful to do so if e.g. the working directory is not writable.

The data directory is used to retain data that must persist from one commandto the next, so it's important to have this variable set consistently throughoutall of the Terraform workflow commands (starting withterraform init) or elseTerraform may be unable to find providers, modules, and other artifacts.

TF_WORKSPACE

For multi-environment deployment, in order to select a workspace, instead of doingterraform workspace select your_workspace, it is possible to use this environment variable. Using TF_WORKSPACE allow and override workspace selection.

For example:

export TF_WORKSPACE=your_workspace

Using this environment variable is recommended only for non-interactive usage, since in a local shell environment it can be easy to forget the variable is set and apply changes to the wrong state.

For more information regarding workspaces, check out the section onUsing Workspaces.

TF_IN_AUTOMATION

IfTF_IN_AUTOMATION is set to any non-empty value, Terraform adjusts itsoutput to avoid suggesting specific commands to run next. This can make theoutput more consistent and less confusing in workflows where users don'tdirectly execute Terraform commands, like in CI systems or other wrappingapplications.

This is a purely cosmetic change to Terraform's human-readable output, and theexact output differences can change between minor Terraform versions.

For more details, seeRunning Terraform in Automation.

TF_REGISTRY_DISCOVERY_RETRY

SetTF_REGISTRY_DISCOVERY_RETRY to configure the max number of request retriesthe remote registry client will attempt for client connection errors or500-range responses that are safe to retry.

TF_REGISTRY_CLIENT_TIMEOUT

The default client timeout for requests to the remote registry is 10s.TF_REGISTRY_CLIENT_TIMEOUT can be configured and increased during extraneous circumstances.

export TF_REGISTRY_CLIENT_TIMEOUT=15

TF_CLI_CONFIG_FILE

The location of theTerraform CLI configuration file.

export TF_CLI_CONFIG_FILE="$HOME/.terraformrc-custom"

TF_IGNORE

IfTF_IGNORE is set to "trace", Terraform will output debug messages to display ignored files and folders. This is useful when debugging large repositories with.terraformignore files.

export TF_IGNORE=trace

For more details on.terraformignore, please seeExcluding Files from Upload with .terraformignore.

Edit this page on GitHub

[8]ページ先頭

©2009-2025 Movatter.jp