TF-004 Interact with Terraform modules Practice Question
A developer creates a directory structure with a module located at './modules/networking'. The root configuration references it with source = './modules/networking'. What is the behavior when running terraform init from the root directory?
⚠ Common exam trap
HashiCorp often tests the misconception that Terraform always requires network access or absolute paths for modules, but the trap here is that local relative paths are fully supported and require no network, no registry, and no absolute path specification.
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
✓
Terraform uses the module directly from the local filesystem.
When a module source is a relative path like './modules/networking', Terraform interprets it as a local filesystem path. During `terraform init`, Terraform reads the module directly from the specified directory without any network access, downloading, or registry interaction. This is the standard behavior for local module references in Terraform.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Terraform uses the module directly from the local filesystem.
Why this is correct
When a module source is specified as a relative or absolute path, Terraform directly accesses the module's contents from the local filesystem. During `terraform init`, Terraform simply ensures the directory exists and contains valid configuration files, without any download operations. This direct access means the module is immediately available for use within the configuration, leveraging the local directory structure.
- ✗
Terraform requires a network connection to verify the module.
Why it's wrong here
Terraform does not require a network connection to verify or utilize modules sourced from the local filesystem. Unlike remote modules that necessitate network access for cloning repositories or downloading archives, local modules are read directly from the machine's disk. All necessary validation, such as syntax checking and dependency resolution, occurs entirely offline within the local environment.
- ✗
Terraform attempts to download the module from the public registry.
Why it's wrong here
Terraform's module source parsing logic distinguishes local filesystem paths from remote registry addresses. When a source string begins with `./`, `../`, or an absolute path, Terraform interprets it as a local module and bypasses any attempts to query the public Terraform Registry. Consequently, no download attempt from the registry occurs, as the module is expected to reside locally.
- ✗
Terraform returns an error because the module path is not absolute.
Why it's wrong here
Terraform explicitly supports and correctly resolves relative paths for local modules, interpreting them relative to the directory of the calling module. An error would only occur if the specified relative path does not point to an existing directory containing valid Terraform configuration, or if there's a syntax error in the path itself. The mere fact that a path is relative, rather than absolute, does not inherently cause an error.
Go deeper
Related to this question
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 →
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.