TF-Associate-004 - Terraform modules - Section 5a

Explain how Terraform sources modules.

The source argument selects a local path, the public or a private registry, a Git or HTTP source, and init retrieves it. Candidates should distinguish a local module from a registry module and know that changing source requires re-running init.

module source argumentlocal versus registry moduleTerraform Registrymodule retrieval during init

Practice question for this objective

Free sampleTerraform modulesmedium

A team edits the source of an existing module block to point at a new registry version, then runs 'terraform plan' straight away without re-running init. What is the most likely outcome?

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "5.1.0"
}
  • AThe plan silently uses the newly requested version because Terraform downloads modules automatically at plan time.
  • BThe plan proceeds using the previously installed version and prints no warning, because the source change takes effect only on the next apply.
  • CThe plan errors and asks the practitioner to run 'terraform init' because the module version currently installed does not satisfy the changed configuration. Correct
  • DTerraform automatically re-runs init as part of plan, downloads the new version, and continues without any prompt.
Terraform installs modules during init, so changing a module source or version requires re-running init before plan can proceed. Module retrieval and installation occur only during terraform init. When the configured source or version no longer matches what is installed under '.terraform/modules', plan halts and instructs the user to run init to install the requested module.

Why A is wrong: This assumes plan performs retrieval, but module installation happens during init, so plan does not fetch the new version on its own.

Why B is wrong: It is tempting to think Terraform quietly keeps the old module, but it detects that the installed module no longer matches the configuration and stops rather than proceeding silently.

Why C is correct: Module retrieval is an init-time step, so a changed source or version that is not yet installed causes plan to fail and direct the user to run init first.

Why D is wrong: Plan never triggers init implicitly; the two are distinct commands, so Terraform will not fetch modules or providers as a side effect of planning.

See more TF-Associate-004 practice questions, answers explained.

More in this domain

Back to all Terraform modules objectives, or the TF-Associate-004 cert hub.

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