nerdexam
HashiCorp

TERRAFORM-ASSOCIATE-004 · Question #267

You have defined the values for your variables in the file terraform.tfvars, and saved it in the same directory as your Terraform configuration. Which of the following commands will use those values w

The correct answer is C. All of the above. Terraform automatically loads variables from terraform.tfvars in the working directory, and also supports explicit loading via the -var-file parameter.

Submitted by noor.lb· Apr 18, 2026Use Terraform CLI

Question

You have defined the values for your variables in the file terraform.tfvars, and saved it in the same directory as your Terraform configuration. Which of the following commands will use those values when creating an execution plan?

Options

  • Aterraform plan
  • Bterraform plan -var-file=terraform.tfvars
  • CAll of the above
  • DNone of the above

How the community answered

(41 responses)
  • B
    2% (1)
  • C
    93% (38)
  • D
    5% (2)

Why each option

Terraform automatically loads variables from `terraform.tfvars` in the working directory, and also supports explicit loading via the `-var-file` parameter.

Aterraform plan

While `terraform plan` alone does work due to automatic loading, it is not the only correct option as explicitly using `-var-file` also works.

Bterraform plan -var-file=terraform.tfvars

While `terraform plan -var-file=terraform.tfvars` works, it is not the only correct option as `terraform plan` alone also works due to automatic loading.

CAll of the aboveCorrect

Terraform automatically discovers and loads variable definitions from files named `terraform.tfvars` or `*.auto.tfvars` present in the current working directory. Additionally, the `-var-file` parameter allows explicit specification of a variable definition file, overriding or merging with other variable sources. Since `terraform.tfvars` is automatically loaded, both `terraform plan` and `terraform plan -var-file=terraform.tfvars` will successfully use the defined values.

DNone of the above

Both option A and option B are valid methods for Terraform to load variables from `terraform.tfvars`, making this choice incorrect.

Concept tested: Terraform variable loading precedence

Source: https://developer.hashicorp.com/terraform/language/values/variables#variable-definition-files

Topics

#terraform plan#variables#terraform.tfvars#CLI commands

Community Discussion

No community discussion yet for this question.

Full TERRAFORM-ASSOCIATE-004 Practice