Skip to main content
Terraform Module Versioning and Shared Registries

Terraform Module Versioning and Shared Registries

KU
· Founder & Chief Editor
• 8 min read•Updated •

Version-pinned modules across many repos. The release process, semver discipline, and the breaking-change communication that keeps a shared registry sane.

Key takeaways

  • Version shared Terraform modules with semver Git tags such as vpc-v1.2.3, and have every consumer pin an exact ref instead of a branch.
  • Keep a changelog with migration notes per module, treat any changed default or new required variable as a major release, and let Dependabot open upgrade PRs for minor and patch versions.

Version shared Terraform modules with semver Git tags (vpc-v1.2.3) and make every consumer pin an exact ref, never a branch. Add a per-module changelog with migration notes, treat anything that can change a consumer's plan as a major release, and let Dependabot propose minor upgrades. A private registry is optional; tags plus discipline are the system.

Verified against

Terraform 1.17 (1.17.1, released 2026-10-28), against the developer.hashicorp.com module source and version constraint docs, the HCP Terraform private registry docs, and GitHub's Dependabot supported-ecosystems reference. Checked October 2026.

The first version of any "shared Terraform module" lives in one repo, sourced by Git URL with a branch reference. Six months later there are ten consumers, three of them are broken by recent module changes, and nobody's sure what version anyone is on. The fix is real version management: semver, a registry or tags, and discipline about breaking changes. This post is the model we run.

Why naked Git references break

When module consumers source by branch:

envs/prod/network.tf
module "vpc" {
  source = "git::ssh://git@github.com/company/tf-modules.git//vpc?ref=main"
}

Every terraform init pulls the current main. Without a ref, Terraform's docs note it clones whatever the default branch HEAD points at, which is the same problem. The module owner ships a change; one consumer's next apply silently inherits it. Sometimes that's fine. Often it isn't.

The failures are predictable:

  • A module owner renames an output; every consumer reading it breaks at the next plan.
  • A module adds a required variable; every consumer's next apply errors.
  • A module renames an internal resource without a moved block; consumers see destroy-and-create in their plans.

Each of these is avoidable with version pinning.

The model

The shape we run:

  1. Modules live in a single repo (tf-modules/) with subdirectories per module. One repo, one CI pipeline, easy to reason about.
  2. Tagged releases follow semver: vpc-v1.2.3, eks-cluster-v3.0.0. Tags are the source of truth for "version X of module Y."
  3. Consumers pin to exact tags (or a full commit SHA, which the docs also support and which can't be moved).
  4. A CHANGELOG.md per module documents every release: what changed, breaking changes called out, migration notes.
  5. Module CI runs terraform validate, terraform test or a small Terratest suite on every PR. PRs to module code can't merge if validation fails.

That's the whole system: Git tags plus discipline.

Semver for modules, applied

Standard semver: MAJOR.MINOR.PATCH.

  • MAJOR: incompatible changes. Renaming variables, removing outputs, changing default values that affect resource shape, requiring a Terraform version bump.
  • MINOR: new features that don't break existing consumers. Adding optional variables, adding outputs, supporting new use cases.
  • PATCH: bug fixes that don't change the interface. Fixing a typo in a tag value, fixing a logic bug in a conditional.

The hard part is deciding what's "breaking." Some changes look minor and aren't:

  • Changing a default value (some consumers depend on the default; their behavior changes).
  • Adding a validation block on an existing variable (existing usage might fail validation now).
  • Renaming an internal resource (consumers get a replace unless you ship a moved block with it).

When in doubt, treat it as breaking. The cost of an unnecessary major version is low; the cost of breaking consumers silently is high.

The release process

A module PR's full lifecycle:

  1. PR opened. CI runs validation and tests. Reviewer assesses changes.
  2. Reviewer assigns a version-impact label: breaking, minor, patch.
  3. On merge, a CI step bumps the version per the label (with release-please or a short script), updates CHANGELOG.md, and creates the Git tag.
  4. The tag is the released version. Consumers can pin to it.

The version-impact label is the integrity check. We require reviewer agreement on the label: the author can propose minor, but the reviewer confirms whether the change is actually breaking.

Consumer-side pinning

Each consumer of a module pins to an exact version:

envs/prod/network.tf
module "vpc" {
  source = "git::ssh://git@github.com/company/tf-modules.git//vpc?ref=vpc-v1.2.3"

  cidr_block = "10.0.0.0/16"
  azs        = ["us-east-1a", "us-east-1b", "us-east-1c"]
}

When the module ships v1.3.0 with a new feature, the consumer doesn't get it automatically. They update the ref and run terraform plan to see what changes. Explicit upgrades are the point.

Dependabot can open those PRs for you. As of October 2026 GitHub's docs list Terraform support for versions 0.13 through 1.15.x, covering modules on the Terraform Registry, publicly reachable Git repos, private registries, and private Git repos once you configure a git registry in dependabot.yml. We auto-suggest minor and patch updates (reviewed, then merged). Major version updates require human consideration.

Breaking-change communication

For breaking releases, the CHANGELOG.md entry includes a "Migration" section:

Markdown
## v3.0.0 - 2026-04-15

### Breaking changes
- Renamed `enable_logs` variable to `enable_flow_logs` for clarity.
- Removed deprecated `legacy_subnet_mode` variable.

### Migration
- Replace `enable_logs = true` with `enable_flow_logs = true` in your consumer.
- If you were using `legacy_subnet_mode`, set `subnet_strategy = "split-az"` to get equivalent behavior.

Major releases also post the migration guide to a Slack channel consumers subscribe to.

We don't force consumers to upgrade on a schedule. They upgrade when they're ready. Older versions remain installable indefinitely, because Git tags never go away.

Avoiding upgrade debt

Old versions remaining usable forever sounds great but accumulates debt. After a year, you can have consumers spread across five major versions of the same module, and security fixes only land on new ones.

Mitigations:

  • Periodic upgrade campaigns. Quarterly, list consumers on old major versions and work with the owning teams to upgrade. A steady process, not a big bang.
  • End-of-life policy. Major versions older than 18 months are marked end-of-life. New security advisories get patched on supported versions only.
  • Compatibility shims for one major version. When we drop a feature, we keep a deprecation path for one major cycle: accept the old input, emit a warning via a check block or output, then remove it in the next major.

What we don't do

Run an HCP Terraform or Terraform Enterprise private registry. It's nice: a UI, real version constraints, module discovery. It also costs money and adds a moving piece. For a single org with a few dozen modules, Git tags plus CHANGELOG.md is enough. If you're weighing hosted options, the Terraform Cloud alternatives comparison covers them.

Floating version ranges (>= 1.0.0, ~> 1.2). These only exist for registry sources; the version argument doesn't apply to Git sources, where ref is always exact. Even with a registry we pin exactly, because the implicit upgrade is the problem we're avoiding.

Per-module Git repos. We use the monorepo for one CI pipeline and easier cross-module changes, at the cost of some merge contention.

Auto-bumping from commit message conventions. Conventional commits can derive the version automatically. We prefer the manual label, because a reviewer judging "is this breaking" catches changed defaults that a feat: prefix hides.

Common mistakes

Skipping the version label on a PR. "It's a small change." Then a consumer breaks. The label discipline only works if applied universally.

Adding required variables in a minor release. A new required variable breaks every consumer who hasn't set it. Required variables mean a major version bump, or add it as optional with a default first.

Combining breaking and non-breaking changes in one release. Bigger blast radius; harder migration. One PR, one logical change.

Letting the CHANGELOG drift. Without it, consumers don't know what changed between versions. Make it part of the merge gate, and track how many versions of each module are in use so fragmentation is visible.

Questions people ask

How do I pin a Terraform module version from Git?

Add ?ref= to the Git source with a tag or a full commit SHA, for example git::ssh://git@github.com/company/tf-modules.git//vpc?ref=vpc-v1.2.3. The version argument only works for registry sources, so for Git the ref is your pin. Without a ref, Terraform clones the default branch, which means every terraform init can pull a different module.

Do I need a private Terraform registry?

Not to get versioning. Git tags give you immutable, pinnable releases for free. A private registry (HCP Terraform, Terraform Enterprise, or a self-hosted one) adds semver range constraints, a browsable catalog and documentation rendering. It starts paying off when many teams discover and consume modules they don't know the owners of. Below that, tags plus a changelog do the job.

What counts as a breaking change in a Terraform module?

Anything that can change a consumer's plan or fail their apply without them editing code: renamed or removed variables and outputs, new required variables, changed defaults, stricter validation blocks, a higher required Terraform or provider version, and resource renames without a moved block. If a consumer bumping the ref would see unexpected diffs, it's a major release.

Module versioning looks bureaucratic and turns out to be operational reliability. Once it lands, it's invisible, which is the goal. Modules ship, consumers upgrade when ready, and breaking changes are visible and signposted.

Sources

React
Share this post
Cite this article
Plain text

Kiril Urbonas (2026). Terraform Module Versioning and Shared Registries. DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/terraform-module-versioning-shared-registries

Markdown

[Terraform Module Versioning and Shared Registries](https://www.devopsness.com/blog/terraform-module-versioning-shared-registries) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)

KU

Kiril Urbonas

Founder & Chief Editor

607 articles
View all articles by Kiril Urbonas

You might have missed

Evergreen posts worth revisiting.