How can Terraform variables be provided to a configuration?

Prepare for the HashiCorp Terraform Associate Exam with quizzes, flashcards, and multiple-choice questions. Each question includes hints and explanations. Boost your confidence and ace your exam!

Multiple Choice

How can Terraform variables be provided to a configuration?

Explanation:
Terraform variables can be provided from multiple sources and overridden at plan or apply time. You can supply values through environment variables (using the TF_VAR_<NAME> prefix), via the -var CLI flag to set a specific value, or with .tfvars files that Terraform reads to fill in variable values. This mix gives you flexibility to keep configuration separate from data and to adapt configurations for different environments without editing the code. Therefore, the method described—environment variables, the -var flag, or .tfvars files—covers the standard ways to provide variable values. The other statements are not accurate because variables aren’t limited to a single file, don’t have to be hard-coded, and can indeed be overridden at apply time through these mechanisms.

Terraform variables can be provided from multiple sources and overridden at plan or apply time. You can supply values through environment variables (using the TF_VAR_ prefix), via the -var CLI flag to set a specific value, or with .tfvars files that Terraform reads to fill in variable values. This mix gives you flexibility to keep configuration separate from data and to adapt configurations for different environments without editing the code. Therefore, the method described—environment variables, the -var flag, or .tfvars files—covers the standard ways to provide variable values. The other statements are not accurate because variables aren’t limited to a single file, don’t have to be hard-coded, and can indeed be overridden at apply time through these mechanisms.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy