TF_VAR_ environment variable
An environment variable named TF_VAR_ followed by a variable name, which Terraform reads as that variable's value.
In more detail
Pipelines use it to inject secrets without writing them into a file. It is overridden by .tfvars files and command-line options, and a forgotten one in your shell profile is a classic cause of a value that will not change.
Example
export TF_VAR_environment=productionRelated terms
- environment variable — A named setting such as PORT=8000 that a program reads from its surroundings when it starts.
- input variable — A named, typed value a configuration or module takes from outside, declared in a variable block and read as var.<name>.
- Terraform variable precedence — The fixed order Terraform uses to decide which value wins when a variable is set in more than one place.
Taught in
- Parameterising With Input Variables — Infrastructure as Code with Terraform
- Input Variables, Outputs, And Which Value Wins — HashiCorp Terraform Associate (004) Exam Prep
- HCP Workspaces, Projects And Variable Sets: Which Value Wins? — HashiCorp Terraform Associate (004) Exam Prep