Chapter 2 of 6 · 4 practices · 3 min · 4-question quiz
Versions and dependencies
How to pin Terraform itself, providers and modules so that a plan run next month uses the same code as the one you reviewed today.
Start: Constrain the Terraform version and every provider4 practices in this chapter
- 1Constrain the Terraform version and every providerA new major provider version can rename arguments or change defaults, and an unpinned configuration picks it up on the next
init. The style guide says to setrequired_versionand to pin every… - 2Commit .terraform.lock.hcl and upgrade providers on purposeThe dependency lock file records the exact provider versions Terraform selected and the checksums of their packages. The Terraform docs recommend committing it, so provider changes go through code…
- 3Pin registry and Git modules to an exact versionBecause module versions are not locked, a loose constraint on a third-party module means its next release lands in your next plan without anyone choosing it. The version constraint docs recommend…
- 4Upgrade Terraform and providers one step at a timeUpgrading Terraform, three providers and two modules in one pull request makes any surprise in the plan impossible to trace. Treat upgrades like any other change: small, planned and reviewed.
Check yourself on this chapter
4 questions, right here once you are signed in. Your progress is saved as you read.