Courseiva

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

    Terraform resolves local module sources as relative paths beginning with ./ or ../, so a subdirectory named networking beneath the root module is referenced as ./networking. This satisfies the stem's relative-location constraint without registry or absolute path syntax.

  • ✗

    ./modules/networking

    Why it's wrong here

    The ./modules/networking path resolves to a modules subdirectory beneath the root, but the stem places the module directly in networking. Local child modules need ./networking. This path would be correct only if the module actually resided inside a modules folder.

  • ✗

    ../networking

    Why it's wrong here

    The ../ prefix traverses upward out of the root module's directory, so ../networking resolves to a sibling of the root rather than the child subdirectory described. Local child modules require the ./ prefix. ../networking would be correct only if the module lived one directory above the root module.

  • ✗

    networking

    Why it's wrong here

    A bare networking string is interpreted as a registry module address, not a local filesystem path, so Terraform would attempt to download it from the registry. Local child modules require the ./ prefix, giving ./networking. The bare form would be correct when referencing a published registry module by name.

About these practice questions

One of 434 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

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 in Terraform module initialization almost always stems from the module's source path being invalid — a typo, wrong relative path, or non-existent registry module. Terraform cannot download or reference the module, so it fails before evaluating variables or version constraints.

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.