Challenge - 5 Problems
Variables and Outputs Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
Understanding Terraform variable default values
You have a Terraform variable defined as:
What will be the value of
variable "region" {
type = string
default = "us-central1"
}What will be the value of
var.region if you do not provide any value during terraform apply?Attempts:
2 left
💡 Hint
Check the default attribute in the variable block.
✗ Incorrect
If a variable has a default value, Terraform uses it when no other value is provided.
❓ Configuration
intermediate2:00remaining
Outputting a resource attribute in Terraform
Given this Terraform resource:
Which output block correctly exports the VM's self_link attribute?
resource "google_compute_instance" "vm" {
name = "my-vm"
machine_type = "e2-medium"
zone = "us-central1-a"
boot_disk {
initialize_params {
image = "debian-cloud/debian-11"
}
}
network_interface {
network = "default"
}
}Which output block correctly exports the VM's self_link attribute?
Attempts:
2 left
💡 Hint
Look for the attribute that uniquely identifies the resource URL.
✗ Incorrect
The self_link attribute provides the full URL of the resource, which is often used as an output.
❓ Architecture
advanced2:30remaining
Passing variables between Terraform modules
You have a root Terraform module that calls a child module. The child module expects a variable named
project_id. Which root module code snippet correctly passes the root variable var.project to the child module?Attempts:
2 left
💡 Hint
Match the variable names expected by the child module with the root variables.
✗ Incorrect
The child module expects a variable named project_id, so the root module must pass var.project to project_id.
❓ security
advanced2:00remaining
Avoiding sensitive data exposure in Terraform outputs
You have a Terraform variable marked as sensitive:
Which output block will cause Terraform to hide the password value when you run terraform apply?
variable "db_password" {
type = string
sensitive = true
}Which output block will cause Terraform to hide the password value when you run terraform apply?
Attempts:
2 left
💡 Hint
Check the Terraform output block attribute to mark outputs as sensitive.
✗ Incorrect
Setting sensitive = true in the output block hides the value in CLI output.
❓ service_behavior
expert3:00remaining
Effect of missing output declaration in Terraform module
You have a Terraform child module that creates a Google Cloud Storage bucket. The child module does NOT declare any outputs.
When you call this module from the root module and run terraform apply, what will be the state of the bucket's URL in the root module?
When you call this module from the root module and run terraform apply, what will be the state of the bucket's URL in the root module?
Attempts:
2 left
💡 Hint
Outputs must be explicitly declared to be accessible outside a module.
✗ Incorrect
Terraform modules only expose outputs that are explicitly declared. Without an output, the root module cannot access the bucket URL.