Terraform Best Practices

Chapter 2 · Practice 4 of 4

Upgrade Terraform and providers one step at a time

From Versions and dependencies

Why it matters

Upgrading 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.

A steady routine:

  1. Read the upgrade notes or changelog for the version you are moving to.
  2. Change one thing: the Terraform version, or one provider, or one module.
  3. Run terraform init -upgrade and terraform plan.
  4. Expect no changes in the plan for a pure upgrade. Any change is either a new default or a bug, and should be understood before you apply.
  5. Commit the updated lock file with the constraint change.

Avoid

  • Bumping several providers and Terraform in one pull request
  • Applying an upgrade whose plan shows changes nobody can explain