TF-Associate-004 domain - 11% of the exam

Terraform modules

Terraform modules is 11% of the HashiCorp Certified: Terraform Associate (TF-Associate-004) exam. These are the objectives it covers, each with practice questions, with every answer explained.

Objectives in this domain

Sample question from this domain

Free sampleTerraform modulesmedium

A practitioner adds a module block that points at a subdirectory of the current project, then runs 'terraform init'. What does Terraform do to retrieve this module?

module "network" {
  source = "./modules/network"
}
  • AIt queries the public Terraform Registry for a module named 'network' and downloads the newest matching version into the cache.
  • BIt reads the module directly from the given relative path on disk without downloading anything, because a source beginning with './' is a local path. Correct
  • CIt clones the path as a Git repository into the '.terraform/modules' directory before the configuration can be used.
  • DIt copies the subdirectory into '.terraform/modules' and thereafter ignores later edits to the original files.
A module source beginning with './' or '../' is a local path that Terraform reads directly without any download. Terraform classifies each module source by its syntax. A relative path prefixed with './' or '../' denotes a local module, so init resolves it against the working directory on disk and never contacts the registry or a remote host.

Why A is wrong: Registry retrieval is tempting because init does fetch registry modules, but a registry source must be a namespaced address such as 'namespace/name/provider', not a relative path.

Why B is correct: A source starting with './' or '../' is a local path, so Terraform reads the files in place during init and performs no download.

Why C is wrong: Git cloning happens only for a Git source address, and a leading './' is never interpreted as a Git URL, so no clone occurs for a local path.

Why D is wrong: This sounds plausible because remote modules are cached under '.terraform/modules', but local modules are referenced in place and edits are picked up on the next run.

Other domains in this exam

See also the TF-Associate-004 cert hub, the study guide, and the cheat sheet.

Examworthy is not affiliated with or endorsed by HashiCorp. Original, blueprint-aligned practice material only.