Challenge - 5 Problems
Terraform Module Output Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate2:00remaining
Understanding Terraform module output usage
Given a Terraform root module that calls a child module which defines an output named
instance_ip, what will be the value of module.webserver.instance_ip after applying the configuration?Terraform
module "webserver" { source = "./modules/aws_instance" instance_count = 1 } output "webserver_ip" { value = module.webserver.instance_ip }
Attempts:
2 left
💡 Hint
Remember that outputs defined in child modules can be accessed via
module.. in the root module.✗ Incorrect
The child module defines an output named
instance_ip. The root module accesses it using module.webserver.instance_ip, which returns the public IP address of the instance created by the child module.❓ Configuration
intermediate2:00remaining
Correctly referencing outputs from a nested module
You have a Terraform module
db that outputs db_endpoint. How do you correctly expose this output in the root module so it can be used elsewhere?Terraform
module "db" { source = "./modules/database" } output "database_endpoint" { value = ??? }
Attempts:
2 left
💡 Hint
Outputs from modules are accessed using
module.. .✗ Incorrect
The correct syntax to access an output from a module is
module.. . Here, module.db.db_endpoint correctly references the output.❓ Architecture
advanced2:00remaining
Impact of missing outputs in Terraform modules
If a Terraform child module creates resources but does not define any outputs, what is the impact on the root module's ability to use information from those resources?
Attempts:
2 left
💡 Hint
Think about how Terraform shares data between modules.
✗ Incorrect
Outputs are the only way for a child module to expose information to the root module. Without outputs, the root module cannot access resource details from the child module.
❓ security
advanced2:00remaining
Security considerations when exposing sensitive outputs from Terraform modules
A Terraform module outputs a sensitive value like a database password using
sensitive = true. What happens if the root module references this output without marking it sensitive?Attempts:
2 left
💡 Hint
Consider how Terraform handles sensitive outputs across module boundaries.
✗ Incorrect
When a child module marks an output as sensitive, the root module must also mark its output referencing it as sensitive to prevent accidental exposure.
✅ Best Practice
expert2:00remaining
Best practice for outputting multiple values from a Terraform module
You want to output multiple related values from a Terraform module, such as instance ID, public IP, and private IP. Which approach is best to keep outputs clean and manageable?
Attempts:
2 left
💡 Hint
Think about how to group related data for easier consumption.
✗ Incorrect
Using a single map output groups related values logically, making it easier to access and maintain outputs from the root module.