Courseiva
Interact with Terraform moduleshardMultiple ChoiceObjective-mapped

TF-004 Interact with Terraform modules Practice Question

An organization stores their Terraform modules in a private Git repository. They need to reference a module that resides in a subdirectory called 'modules/rds' within the repository 'infra-modules' on the main branch. Which source argument should be used?

⚠ Common exam trap

The key trap in this question is that candidates confuse the double-slash (`//`) syntax with a colon (`:`) or forget to include the subdirectory path entirely, leading them to pick options that either point to the root or use incorrect separators.

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

source = "git::https://github.com/org/infra-modules.git//modules/rds"

Terraform's module source syntax for Git repositories uses a double slash (`//`) to specify a subdirectory within the repository. The format `git::https://github.com/org/infra-modules.git//modules/rds` tells Terraform to clone the repository at the main branch and then use the module located in the `modules/rds` subdirectory. This is the standard way to reference a module in a subdirectory of a Git repository.

Answer analysis

Option-by-option breakdown

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

  • source = "git::https://github.com/org/infra-modules.git//modules/rds"

    Why this is correct

    This module source declaration is correctly formatted for a Git repository. The `git::` prefix explicitly tells Terraform to use the Git protocol. Crucially, the double-slash `//` acts as the required delimiter, separating the main repository URL from the subdirectory path `modules/rds` where the actual module code resides. This ensures Terraform fetches the specific module from its intended location within the repository.

  • source = "git::https://github.com/org/infra-modules.git"

    Why it's wrong here

    This module source is incorrect because it points directly to the root of the `infra-modules.git` repository without specifying a subdirectory. Terraform expects the module's root directory, containing files like `main.tf` and `variables.tf`, to be at the path indicated. If the `rds` module is nested within `modules/rds`, Terraform will fail to locate the necessary module configuration files at the repository's top level.

  • source = "git::https://github.com/org/infra-modules.git:modules/rds"

    Why it's wrong here

    This module source string is improperly formatted due to the use of a colon `:` as a delimiter for the subdirectory path. Terraform's specific syntax for sourcing modules from Git repositories mandates the use of a double-slash `//` to separate the repository URL from the module's subdirectory path. The colon character is not recognized for this purpose, resulting in a parsing error or an inability to correctly resolve the module.

  • source = "git::https://github.com/org/infra-modules.git//rds"

    Why it's wrong here

    While this option correctly uses the `git::` prefix and the double-slash `//` delimiter, the specified subdirectory path `//rds` is incorrect. The problem statement implies the `rds` module is located at `modules/rds` within the repository. Terraform will attempt to find the module directly under a top-level `rds` directory, failing to locate the actual module code at the deeper `modules/rds` path.

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.