Courseiva
Interact with Terraform moduleshardMultiple SelectObjective-mapped

TF-004 Module Outputs Practice Question

Which THREE of the following are valid ways to reference a module output value within the same Terraform configuration?

⚠ Common exam trap

Module outputs are valid in resource arguments, count/for_each, data source filter blocks, and locals blocks. They cannot be used in provider blocks because provider configurations are static and resolved before any other resources are evaluated.

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

In the count or for_each of another module or resource.

Options A, B, C, and E are correct ways to reference a module output value within the same Terraform configuration. Module outputs can be used in `count` or `for_each` meta-arguments (A), directly in resource arguments (B), in data source filter blocks (C), and in `locals` blocks for transformation (E). Option D is incorrect because provider blocks require static configuration and cannot reference module outputs; provider configurations are resolved before any resources or modules.

Answer analysis

Option-by-option breakdown

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

  • In the count or for_each of another module or resource.

    Why this is correct

    Module outputs can control the number of instances or the iteration set of other resources.

  • In a resource argument, e.g., subnet_id = module.vpc.public_subnet_ids

    Why this is correct

    Directly using module outputs in resource arguments is the most common use case.

  • In a data source definition as a filter.

    Why this is correct

    Correct. Module output values can be used in data source filter blocks, such as `filter { name = "tag:Name" values = [module.vpc.name] }`. Terraform handles the dependency graph, so this is valid.

  • In a provider block to set endpoints.

    Why it's wrong here

    Provider configurations are static and cannot reference interpolations from module outputs.

  • In a locals block to perform transformations.

    Why this is correct

    Locals can use module outputs to derive new local values.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

About these practice questions

This TF-004 question is part of Courseiva's 428-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. 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.