terraform init -upgrade
The init option that ignores the versions in the lock file and picks the newest provider and module versions the constraints still allow.
In more detail
It rewrites the dependency lock file, which you then review and commit as its own change. Without it, init keeps whatever the lock file already records, even if newer versions exist.
Related terms
- terraform init — The command that prepares a directory for Terraform: it downloads providers, fetches modules, connects the backend and writes the lock file.
- dependency lock file — The .terraform.lock.hcl file that terraform init writes to record the exact provider versions chosen and their checksums.
- version constraint — A string such as "~> 3.6" or ">= 1.6.0" that says which versions of Terraform, a provider or a module are acceptable.
Taught in
- Providers And The required_providers Block — Infrastructure as Code with Terraform
- Initialising The Working Directory — Infrastructure as Code with Terraform
- Versions, The Lock File And Provider Aliases — HashiCorp Terraform Associate (004) Exam Prep
- Write, Plan, Apply, And What Init Prepares — HashiCorp Terraform Associate (004) Exam Prep
- Module Versions: Pin, Upgrade, Re-Initialise — HashiCorp Terraform Associate (004) Exam Prep
- Trap Sprint: Twelve Answers That Are Almost True — HashiCorp Terraform Associate (004) Exam Prep