Courseiva
Interact with Terraform moduleseasyMultiple ChoiceObjective-mapped

TF-004 Interact with Terraform modules Practice Question

A Terraform module defines an output 'instance_ips'. In the root module, how should this value be referenced?

⚠ Common exam trap

Terraform certification exams often test the distinction between `var.*`, `local.*`, `resource.*`, and `module.*` references, and the trap here is that candidates confuse module outputs with resource attributes, incorrectly using `resource.my_module.instance_ips` instead of the correct `module.my_module.instance_ips` syntax.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

module.my_module.instance_ips

Outputs from a child module are accessed in the root module using the `module.<module_name>.<output_name>` syntax. The `module` keyword is a reserved reference that Terraform uses to expose all outputs defined within a module block, allowing the root configuration to consume values like `instance_ips` as `module.my_module.instance_ips`.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • var.instance_ips

    Why it's wrong here

    The `var.` prefix is exclusively used to reference input variables that are declared within `variable` blocks in the current module or root configuration. These variables provide configurable values *to* the module, allowing its behavior to be customized. It is incorrect to use `var.` to access an output value *from* another module, as outputs are distinct from input variables and serve to expose computed values *from* a module.

  • local.instance_ips

    Why it's wrong here

    The `local.` prefix is used to reference local values, which are named expressions defined using `locals` blocks within the *same* module. These values are internal to the module where they are declared and are primarily used for intermediate computations or to simplify complex expressions. Therefore, `local.instance_ips` would attempt to find a local value named `instance_ips` within the current module, not an output from a separate module.

  • resource.my_module.instance_ips

    Why it's wrong here

    The `resource.` prefix is specifically used to reference attributes of a *resource* block defined within the Terraform configuration, following the pattern `resource.<RESOURCE_TYPE>.<RESOURCE_NAME>.<ATTRIBUTE>`. While a module might *create* resources, the module itself is not directly referenced as a resource type in this manner. Accessing an output from a module requires the `module.` prefix, as `resource.my_module.instance_ips` incorrectly implies `my_module` is a resource type.

  • module.my_module.instance_ips

    Why this is correct

    This is the correct and standard syntax for referencing an output value from a child module. When a module is declared and given a local name (e.g., `my_module`) in a `module` block, its defined output values become accessible using the `module.<MODULE_NAME>.<OUTPUT_NAME>` pattern. This allows the root module or other child modules to consume the computed results exposed by `my_module`, such as a list of instance IPs.

About these practice questions

One of 428 original TF-004 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.