Skill 4.3.2
Assigning variable values and precedence
Key Concepts
Values can come from a default, environment variables named TF_VAR_name, variable definition files and command-line options. Terraform automatically loads terraform.tfvars, terraform.tfvars.json and any files ending in .auto.tfvars or .auto.tfvars.json; other files need -var-file=FILE. Single values can be set with -var='name=value'.
When a variable is set in several places, Terraform uses the last value in this order: environment variables, then terraform.tfvars, then terraform.tfvars.json, then *.auto.tfvars and *.auto.tfvars.json files in lexical order of their names, then any -var and -var-file options in the order given on the command line. The default applies only when no other value is given. In HCP Terraform, workspace variables play the role of these sources.