TA-002-P · Question #363
In the below configuration, how would you reference the module output vpc_id ? Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct answer…
The correct answer is A. module.vpc.id. To reference an output variable from a Terraform module, the syntax is module.module_local_name.output_variable_name.
Question
In the below configuration, how would you reference the module output vpc_id ? Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct answer are accepted.
Options
- Amodule.vpc.id
- Bmodule.vpc.ie
How the community answered
(31 responses)- A94% (29)
- B6% (2)
Why each option
To reference an output variable from a Terraform module, the syntax is `module.module_local_name.output_variable_name`.
In Terraform, outputs from a module are referenced using the format `module.module_local_name.output_variable_name`. Given the module's local name is `vpc` and the output variable is `vpc_id`, the correct reference would be `module.vpc.id` if the output name within the module is `id` (common practice for VPC IDs).
`module.vpc.ie` is a typo and not a valid reference for `vpc_id`.
Concept tested: HCL module output referencing syntax
Source: https://developer.hashicorp.com/terraform/language/values/outputs
Topics
Community Discussion
No community discussion yet for this question.