TERRAFORM-ASSOCIATE-004 · Question #60
You are using a networking module in your Terraform configuration with the name label my- network. In your main configuration you have the following code: When you run terraform validate, you get…
The correct answer is C. Define the attribute vnet_id as an output in the networking module. To expose a value from a child module to its caller, the value must be explicitly declared as an output in that module. The correct reference syntax is module.<module_name>.<output_name> (e.g., module.my-network.vnet_id). Simply declaring a variable inside the module is not…
Question
Exhibit
Options
- AChange the reference value to my-network,outputs,vmet_id
- BDefine the attribute vmet_id as a variable in the networking modeule
- CDefine the attribute vnet_id as an output in the networking module
- DChange the reference value module.my,network,outputs,vnet_id
How the community answered
(41 responses)- A2% (1)
- B2% (1)
- C88% (36)
- D7% (3)
Explanation
To expose a value from a child module to its caller, the value must be explicitly declared as an output in that module. The correct reference syntax is module.<module_name>.<output_name> (e.g., module.my-network.vnet_id). Simply declaring a variable inside the module is not sufficient - outputs act as the module's public interface. Without an output declaration, Terraform cannot resolve the reference and will throw a validation error.
Topics
Community Discussion
No community discussion yet for this question.
