Courseiva
Interact with Terraform moduleseasyMultiple SelectObjective-mapped

TF-004 Interact with Terraform modules Practice Question

Which TWO statements about Terraform modules are correct?

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

A module can be called multiple times in the same configuration with different input variables.

Terraform modules can be called multiple times with different input variables, enabling reuse. Option E is correct because module sources can be Git repository URLs with a specific commit SHA (e.g., using `?ref=<sha>`). Option A is incorrect because the `count` meta-argument is supported on module blocks in Terraform 0.13 and later. Option B is incorrect because module outputs are not automatically available; they must be referenced explicitly as `module.<module_name>.<output_name>`. Option C is incorrect because version constraints are optional for reproducibility; they are recommended but not mandatory.

Answer analysis

Option-by-option breakdown

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

  • The count meta-argument is not supported on module blocks.

    Why it's wrong here

    This statement is incorrect. Terraform 0.13 introduced support for both the `count` and `for_each` meta-arguments on module blocks, allowing practitioners to instantiate multiple copies of a module dynamically. This feature is crucial for managing collections of similar infrastructure components without duplicating module calls in the configuration. When `count` is used, the module creates `count.index` instances, each accessible via `module.module_name[index]`.

  • Module outputs are automatically available as inputs to other modules in the same configuration.

    Why it's wrong here

    This statement is incorrect because module outputs are not automatically exposed or available globally within a Terraform configuration. To utilize an output from one module as an input for another module or resource, it must be explicitly referenced using the syntax `module.<MODULE_NAME>.<OUTPUT_NAME>`. This explicit dependency declaration ensures clarity, prevents naming collisions, and establishes a clear data flow graph within the configuration.

  • Module sources must include a version constraint to ensure reproducibility.

    Why it's wrong here

    This statement is incorrect. While highly recommended for production environments to ensure consistent and reproducible deployments, module sources are not strictly required to include a version constraint. Terraform allows module sources without explicit versioning, defaulting to the latest available version or the main branch for Git repositories. However, omitting version constraints can lead to unexpected changes in infrastructure if the upstream module is updated, making reproducibility challenging.

  • A module can be called multiple times in the same configuration with different input variables.

    Why this is correct

    This statement is correct. One of the primary benefits of Terraform modules is their reusability, allowing a single module definition to be invoked multiple times within the same root configuration. Each invocation can be given a unique local name and supplied with different input variables, enabling the deployment of distinct instances of similar infrastructure components. This pattern promotes DRY (Don't Repeat Yourself) principles and simplifies managing complex, multi-environment, or multi-tenant infrastructure.

  • The source attribute of a module can be a Git repository URL with a specific commit SHA.

    Why this is correct

    This statement is correct. Terraform supports various module sources, including Git repositories. When specifying a Git repository as a module source, it is possible and often recommended to append a `?ref=<COMMIT_SHA>` query parameter to the URL. This allows Terraform to fetch the module from a precise commit hash, ensuring that the exact version of the module code is used, which is critical for reproducibility and immutability of infrastructure deployments.

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.