Recall & Review
beginner
What is the purpose of environment variables prefixed with
TF_VAR_ in Terraform?They allow you to set Terraform input variables outside of configuration files, making it easier to manage sensitive or environment-specific values.
Click to reveal answer
beginner
How does Terraform use an environment variable named
TF_VAR_region?Terraform automatically maps
TF_VAR_region to the input variable named region in your Terraform configuration.Click to reveal answer
intermediate
Why might you prefer using
TF_VAR_ environment variables over hardcoding variables in Terraform files?Using
TF_VAR_ environment variables keeps sensitive data out of code, supports different environments easily, and avoids committing secrets to version control.Click to reveal answer
intermediate
Can you use
TF_VAR_ environment variables to set complex types like lists or maps in Terraform?Yes, but you must provide the value as a JSON string that Terraform can parse into the complex type.
Click to reveal answer
intermediate
What happens if both a Terraform variable file and a
TF_VAR_ environment variable set the same variable?The
TF_VAR_ environment variable takes precedence over the variable file value.Click to reveal answer
What prefix must an environment variable have to be recognized by Terraform as an input variable?
✗ Incorrect
Terraform recognizes environment variables starting with TF_VAR_ as input variables.
How should you format a list variable when setting it via a TF_VAR_ environment variable?
✗ Incorrect
Terraform expects complex types like lists to be passed as JSON strings in TF_VAR_ environment variables.
If you set a variable in both a .tfvars file and a TF_VAR_ environment variable, which one does Terraform use?
✗ Incorrect
TF_VAR_ environment variables override values set in .tfvars files.
Why is using TF_VAR_ environment variables considered a best practice for sensitive data?
✗ Incorrect
Using environment variables avoids storing secrets in code or version control systems.
Which of the following is a valid TF_VAR_ environment variable for a Terraform variable named 'password'?
✗ Incorrect
The correct syntax is TF_VAR_variableName=value without quotes or special characters.
Explain how Terraform uses environment variables prefixed with TF_VAR_ to set input variables.
Think about how environment variables can replace or override variable files.
You got /3 concepts.
Describe best practices and benefits of using TF_VAR_ environment variables in Terraform projects.
Consider security and flexibility advantages.
You got /4 concepts.