dependency lock file
The .terraform.lock.hcl file that terraform init writes to record the exact provider versions chosen and their checksums.
In more detail
Commit it, so every teammate and every pipeline gets exactly the same provider builds. The checksums make Terraform reject a provider package that has been tampered with. To take newer versions on purpose, run terraform init -upgrade and commit the changed file as its own reviewed change.
Example
provider "registry.terraform.io/hashicorp/local" {
version = "2.5.2"
constraints = "~> 2.5"
hashes = [ "h1:...", ]
}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.
- 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.
- 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.
- hash — A short fixed-length fingerprint calculated from data, which changes completely if even one byte of the data changes.
- pinning — Fixing an exact version or digest of something you depend on so it cannot change without you noticing.
Related guides
Taught in
- Providers And The required_providers Block — Infrastructure as Code with Terraform
- Initialising The Working Directory — Infrastructure as Code with Terraform
- The Terraform Registry And Public Modules — Infrastructure as Code with Terraform
- Running Terraform In CI — Infrastructure as Code with Terraform
- Providers: How Terraform Reaches Every API — HashiCorp Terraform Associate (004) Exam Prep
- Versions, The Lock File And Provider Aliases — HashiCorp Terraform Associate (004) Exam Prep
- State: Terraform's Memory Of What It Built — HashiCorp Terraform Associate (004) Exam Prep
- Write, Plan, Apply, And What Init Prepares — HashiCorp Terraform Associate (004) Exam Prep
- Where Modules Come From — HashiCorp Terraform Associate (004) Exam Prep
- Module Versions: Pin, Upgrade, Re-Initialise — HashiCorp Terraform Associate (004) Exam Prep
- State Locking: One Writer At A Time — HashiCorp Terraform Associate (004) Exam Prep
- Trap Sprint: Twelve Answers That Are Almost True — HashiCorp Terraform Associate (004) Exam Prep