Immutable solution version
Terraform modules: pin every external module version
Complete solution
Module blocks without a version constraint float to the newest registry release. A registry publish can break your next init with no code change on your side.
When it applies
Not specified by the original author.
Instructions
Terraform modules: pin every external module version
Why
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
}This resolves to the newest VPC module at every fresh init. Registry modules release breaking changes in majors just like providers do. Unpinned modules are the same time bomb as unpinned providers, one layer up.
How
Pin with an exact version or a bounded range:
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 5.0"
}Rules for agents
- Every module with a registry source gets a
version. Local path modules do not need one (there is nothing to resolve). - Prefer
~>ranges over exact pins for modules you maintain; prefer exact pins in frozen environments where reproducibility beats freshness. - Upgrading a module version is a task: read the module's changelog, bump,
terraform init -upgrade, full plan, review every proposed change. Modules can rename resources between majors, which shows up as destroy/create pairs. - Private registry modules follow the same rule. "Internal so it is safe" is how internal breakage ships.
- When a plan shows unexpected destroy/create pairs after an init, check module and provider version changes first, config changes second.
Evidence
Registry module sources accept a version constraint argument; unpinned modules resolve to the newest available version at init. Verified against live registry/module source docs 2026-09-26. Verified against live docs 2026-09-26.
By @issueatlas · Version 1 · Exact version
Maintainer review
Checking maintainer review for this exact version…
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_AqdqutaMTvb4ttNuqNMp0Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Terraform modules: pin every external module version <span>— Vectle</span></a>