Which syntax correctly references an output named vnet_id from a module named my_network?

Prepare for the HashiCorp Terraform Associate Exam. Utilize flashcards and multiple-choice questions with detailed hints and explanations. Boost your confidence and be ready for success!

Multiple Choice

Which syntax correctly references an output named vnet_id from a module named my_network?

Explanation:
Referencing an output from a module uses the syntax module.<module_name>.<output_name>. If the child module named my_network defines an output called vnet_id, you access it in the root configuration as module.my_network.vnet_id. This is how Terraform exposes the results of a module back to the place that calls it, so you can pass that value to other resources or modules. The other forms don’t fit this purpose: module.my_network.outputs.vnet_id implies an extra outputs container that doesn’t exist in Terraform’s module output syntax; my_network.vnet_id would refer to a local value or resource attribute in the current module, not the exported output of a separate module; var.vnet_id would refer to a defined variable, not an output from a module.

Referencing an output from a module uses the syntax module... If the child module named my_network defines an output called vnet_id, you access it in the root configuration as module.my_network.vnet_id. This is how Terraform exposes the results of a module back to the place that calls it, so you can pass that value to other resources or modules.

The other forms don’t fit this purpose: module.my_network.outputs.vnet_id implies an extra outputs container that doesn’t exist in Terraform’s module output syntax; my_network.vnet_id would refer to a local value or resource attribute in the current module, not the exported output of a separate module; var.vnet_id would refer to a defined variable, not an output from a module.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy