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

Manage module versions.

The version argument, supported for registry modules, pins or constrains a module version so upgrades are deliberate. Candidates should reason about version constraints on modules and why pinning protects against an unexpected upstream change.

module version argumentversion constraintsregistry module versioningdeliberate module upgrades

Practice question for this objective

Free sampleTerraform modulesmedium

Why is pinning a registry module to a specific version considered good practice for deliberate upgrades?

  • AIt makes Terraform fetch the newest available release on every init so the configuration stays current automatically.
  • BIt removes the need to run terraform init after the module author publishes a new release.
  • CIt gives repeatable installs, so a module upgrade happens only when someone changes the constraint and reviews the new version. Correct
  • DIt allows the module to skip provider version resolution because the pinned module already carries compatible providers.
Explain that pinning a module version gives repeatable installs and makes upgrades deliberate and reviewable. A fixed version constraint resolves to the same module release on every run and every machine, so adopting a newer release requires a conscious edit that can be reviewed and tested rather than being pulled in silently.

Why A is wrong: This describes the opposite behaviour; automatic newest fetching is what pinning is meant to prevent, since it can introduce unreviewed changes.

Why B is wrong: This is tempting because pinning does reduce churn, but a new release still requires editing the constraint and re-initialising to adopt it, so init is not eliminated.

Why C is correct: Pinning fixes the resolved version across runs and machines, so a version change is an explicit, reviewable edit rather than an implicit shift when the registry gains a release.

Why D is wrong: Module version pinning does not bypass provider constraint resolution; providers are still resolved separately during init regardless of how the module is pinned.

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.