Courseiva
Interact with Terraform modulesmediumMultiple ChoiceObjective-mapped

TF-004 Interact with Terraform modules Practice Question

Exhibit

Refer to the exhibit.

```hcl	erraform {
  required_version = ">= 1.0"
}

module "network" {
  source = "./modules/networking"
  vpc_id = "vpc-12345"
}
```

Output from `terraform plan`:
```
Error: Module not found

The module at "./modules/networking" could not be found.
```

What is the most likely cause of this error?

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

The module source path does not exist.

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.

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 module requires a version constraint.

    Why it's wrong here

    Version constraints, specified using the `version` argument in a `module` block, are primarily used for modules sourced from a registry (like the Terraform Registry) or a Git repository. For local modules, which are referenced directly by their file system path, Terraform does not apply or require version constraints because the module's content is immediately available and not subject to remote versioning protocols. Therefore, a missing version constraint would not cause a 'module not found' error for a local path.

  • The module source path does not exist.

    Why this is correct

    When a local module is referenced using a relative or absolute file system path, Terraform attempts to locate and read the module's configuration files within that specified directory. If the directory indicated by the `source` attribute, such as './modules/networking', does not exist on the file system, Terraform cannot proceed with loading the module. This directly results in an error indicating that the module source path is invalid or cannot be found, preventing any further processing of the module's contents.

  • The required_version is incompatible with the module.

    Why it's wrong here

    The `required_version` attribute is defined within the `terraform` block and specifies the compatible versions of the Terraform CLI itself, not the versions of individual modules. If the running Terraform CLI version is incompatible with the `required_version` constraint, Terraform would halt execution with an error specifically stating a version mismatch for the CLI. It would not manifest as an error about a module's source path being unavailable or unlocatable.

  • The module input variable 'vpc_id' is not defined in the module.

    Why it's wrong here

    If an input variable like 'vpc_id' were declared in the calling module but not defined within the called module's `variables.tf` file, Terraform would produce a distinct validation error. This error would clearly state that the variable is undeclared or undefined within the module's scope, rather than indicating a failure to find the module's source directory entirely. The module itself would still be located and parsed, but its internal configuration would be deemed invalid due to the missing variable definition.

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.