
version argument in the module block. For example, to pin the module to version 5.12.0:
terraform init, Terraform will download the specified module version (5.12.0 in this example) and continue to use that version for plan and apply operations.
If you prefer to allow non-breaking updates but avoid major bumps, use version constraints. The table below summarizes common patterns and their behavior.
| Constraint pattern | Meaning | Example |
|---|---|---|
| Exact version | Only this exact release will be used | version = "5.12.0" |
| Patch-compatible updates | Allows patch releases within the same minor version (safe bug fixes) | version = "~> 5.12.0" |
| Any 5.x release (no 6.x) | Accepts newer minor and patch updates but prevents major version 6 | version = ">= 5.12.0, < 6.0.0" |
version in the module block and run terraform init -upgrade to re-download the module:
- Pin module versions or use constrained ranges to reduce risk from breaking changes.
- Test module upgrades in non-production environments before promoting to production.
- Read the module’s CHANGELOG and release notes to understand breaking changes and migration steps.
- Consider using CI pipelines to validate
terraform planafter upgrading module versions.
Pin module versions (or use constrained version ranges) and test module upgrades in non-production environments before promoting them to production. This reduces the risk of unexpected breaking changes.
- Terraform Registry
- Semantic Versioning (semver)
- Terraform CLI:
terraform init,terraform init -upgrade