Skill 5.4.2

Pinning and upgrading module versions

Key Concepts

The dependency lock file does not record module versions. When a constraint allows a range, terraform init keeps an already installed module version that still matches, and terraform init -upgrade installs the newest version that the constraint allows. For reproducible builds, many teams pin modules to an exact version or a Git tag and update them through reviewed pull requests.

When upgrading a module, read its changelog, change the version, run terraform init -upgrade and review the plan carefully: renamed resources inside a new major version should come with moved blocks so that existing objects are not destroyed.