Challenge - 5 Problems
Terraform Module Inputs Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding Terraform module variable defaults
Given a Terraform module with a variable defined as
variable "region" { default = "us-west-1" }, what will be the value of var.region inside the module if the caller does NOT provide a value?Attempts:
2 left
💡 Hint
Think about what happens when a variable has a default value and no override is given.
✗ Incorrect
If a variable has a default value and the caller does not provide a value, Terraform uses the default inside the module.
❓ Configuration
intermediate2:00remaining
Passing variables to a Terraform module
You have a Terraform module that expects a variable
instance_count. Which of the following is the correct way to pass the value 3 to this variable when calling the module?Terraform
module "webserver" { source = "./modules/webserver" // fill in here }
Attempts:
2 left
💡 Hint
Remember how to assign values to module inputs in the module block.
✗ Incorrect
Inside the module block, you assign values to variables by using
variable_name = value syntax.❓ Architecture
advanced2:00remaining
Variable type constraints in Terraform modules
A module variable is defined as
variable "tags" { type = map(string) }. Which of the following values passed to this variable will cause a Terraform plan error?Attempts:
2 left
💡 Hint
Consider the expected type and what each option represents.
✗ Incorrect
The variable expects a map of strings. Option D is a list, not a map, so it causes a type error.
❓ security
advanced2:00remaining
Sensitive variables in Terraform modules
You want to pass a password to a Terraform module variable without showing it in logs or state files. Which variable attribute should you use inside the module to mark it as sensitive?
Attempts:
2 left
💡 Hint
Terraform has a specific attribute to mark variables as sensitive.
✗ Incorrect
The 'sensitive = true' attribute marks variables so their values are not shown in logs or UI.
❓ service_behavior
expert2:00remaining
Effect of missing required module variables
A Terraform module defines a variable
project_id without a default value. The caller does NOT provide a value for this variable. What happens when you run terraform apply?Attempts:
2 left
💡 Hint
Think about how Terraform handles required variables without defaults and no input.
✗ Incorrect
Terraform will prompt the user to enter a value for required variables without defaults before applying.