Recall & Review
beginner
What is the highest precedence source for Terraform input variables?
Command-line flags (e.g., -var or -var-file) have the highest precedence and override all other sources.
Click to reveal answer
intermediate
List the order of precedence for Terraform input variables from highest to lowest.
1. Command-line flags (-var, -var-file)
2. Environment variables (TF_VAR_name)
3. terraform.tfvars files and other tfvars files
4. Default values in variable blocks
Click to reveal answer
beginner
How do environment variables affect Terraform input variables?
Environment variables prefixed with TF_VAR_ set the value of input variables and override values from tfvars files and defaults, but are overridden by command-line flags.
Click to reveal answer
beginner
What happens if a variable is not set by any source in Terraform?
Terraform uses the default value defined in the variable block. If no default is set and the variable is required, Terraform will prompt the user for input.
Click to reveal answer
intermediate
Why is understanding input variable precedence important in Terraform?
It helps avoid unexpected values by knowing which source will override others, ensuring predictable and controlled infrastructure configuration.
Click to reveal answer
Which source has the lowest precedence for Terraform input variables?
✗ Incorrect
Default values in variable blocks have the lowest precedence and are used only if no other source provides a value.
If a variable is set in both an environment variable and a terraform.tfvars file, which value does Terraform use?
✗ Incorrect
Environment variables override values set in terraform.tfvars files.
How can you override a Terraform variable value without changing any files?
✗ Incorrect
Passing variables via command-line flags overrides all other sources.
What prefix must environment variables have to set Terraform input variables?
✗ Incorrect
Environment variables must be prefixed with TF_VAR_ followed by the variable name.
If a required variable has no default and is not set by any source, what does Terraform do?
✗ Incorrect
Terraform prompts the user to input a value for required variables without defaults.
Explain the order in which Terraform applies input variable values from different sources.
Think about which source you would want to override others when running Terraform.
You got /4 concepts.
Describe what happens when a Terraform variable is not set anywhere and has no default value.
Consider how Terraform ensures required variables have values.
You got /3 concepts.