What is the purpose of terraform.tfvars file?

  1. To store Terraform state
  2. To provide values for input variables without modifying configuration files ✓
  3. To define backend configuration
  4. To configure provider credentials

Correct answer: To provide values for input variables without modifying configuration files

Option B is correct because terraform.tfvars is a variable definitions file that supplies concrete values for input variables declared in configuration files, keeping sensitive or environment-specific values separate from reusable module code. Option A is incorrect because Terraform state is stored in terraform.tfstate, not in .tfvars files. Option C is incorrect because backend configuration is defined in a backend block within a .tf configuration file, typically backend.tf, not in .tfvars. Option D is incorrect because provider credentials are most securely supplied via environment variables or a dedicated credentials file, and while .tfvars could technically hold them, that is not their purpose and is considered a security anti-pattern.

Topic: · terraform, variables, tfvars, infrastructure-as-code

Practice HashiCorp Terraform Associate (003) Questions Free