Specifying Local Terraform Module Source Path — ./ vs ../
A developer creates a module in a subdirectory called 'networking' relative to the root module. How should the module source be specified in the root module?
Quick Answer
The answer is ./networking. This is correct because Terraform requires local module source paths to begin with either ./ or ../ to distinguish them from registry or remote module references, and ./networking explicitly points to the networking subdirectory within the same root module directory. On the HashiCorp Terraform Associate TF-003 exam, this tests your understanding of module source path syntax, a common trap being that ../networking would incorrectly navigate up one directory level instead of referencing a sibling subdirectory. A reliable memory tip is to think of the dot as meaning "current directory" — just as you would type ./script.sh to run a local script, you use ./modulename to reference a local module.
⚠ Common exam trap
A common mistake on the Terraform exam is confusing local module paths (requiring './' or '../') with registry module references (bare name or 'namespace/name/provider'). Candidates often omit the './' prefix and incorrectly select a bare name like 'networking'.
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
✓
./networking
When referencing a local module in a subdirectory relative to the root module, the correct path prefix is './' followed by the subdirectory name. Option A, './networking', correctly uses a relative path starting with './' to indicate the 'networking' directory is a child of the root module's directory. This is the standard Terraform convention for local module sources.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
./networking
Why this is correct
The path starts with './' indicating a relative path from the current directory.
- ✗
./modules/networking
Why it's wrong here
This assumes a 'modules' subdirectory structure that does not exist.
- ✗
../networking
Why it's wrong here
This goes up one directory level, not down into the 'networking' subdirectory.
- ✗
networking
Why it's wrong here
Without './', Terraform may interpret this as a module registry name or alias, not a local path.
Go deeper
Related to this question
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 →
Same concept, more angles
2 more ways this is tested on TF-004
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A developer creates a module in a subdirectory of their Terraform configuration and wants to reference it from the root module. The directory structure is: /terraform-project/modules/networking. Which source argument should they use in the module block?
medium- A.source = "file:///terraform-project/modules/networking"
- B.source = "/terraform-project/modules/networking"
- ✓ C.source = "./modules/networking"
- D.source = "hashicorp/networking/aws"
Why C: Terraform resolves local module paths relative to the root module's directory. The path `./modules/networking` correctly references the `networking` subdirectory within the `modules` folder, starting from the root of the Terraform configuration. This is the standard syntax for referencing a local module in a subdirectory.
Variation 2. What is the most likely cause of this error?
medium- A.The module requires a version constraint.
- ✓ B.The module source path does not exist.
- C.The required_version is incompatible with the module.
- D.The module input variable 'vpc_id' is not defined in the module.
Why B: The error message indicates that the module source path does not exist. Terraform cannot find the specified local path for the module. Option A is incorrect because version constraints are not required for local module sources; they are used for registry modules. Option C is incorrect because the `required_version` setting in Terraform configuration controls the Terraform version, not module sourcing. Option D is incorrect because the error is about locating the module source, not about an undefined input variable.
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.