nerdexam
HashiCorp

TA-002-P · Question #252

You have created a custom variable definition file my_vars.tfvars. How will you use it for provisioning infrastructure?

The correct answer is D. terraform apply -var-file="my_vars.tfvars". To set lots of variables, it is more convenient to specify their values in a variable definitions file (with a filename ending in either .tfvars or .tfvars.json) and then specify that file on the command line with -var-file: terraform apply -var-file="my_vars.tfvars"

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

Question

You have created a custom variable definition file my_vars.tfvars. How will you use it for provisioning infrastructure?

Options

  • Aterraform apply -var-state-file ="my_vars.tfvars"
  • Bterraform apply var-file="my_vars.tfvars"
  • Cterraform plan -var-file="my_vars.tfvar"
  • Dterraform apply -var-file="my_vars.tfvars"

How the community answered

(48 responses)
  • A
    2% (1)
  • B
    6% (3)
  • C
    2% (1)
  • D
    90% (43)

Explanation

To set lots of variables, it is more convenient to specify their values in a variable definitions file (with a filename ending in either .tfvars or .tfvars.json) and then specify that file on the command line with -var-file: terraform apply -var-file="my_vars.tfvars"

Topics

#terraform apply#variables#tfvars files#CLI usage

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice