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.
In more detail
A bare number means exactly that version; >= means that version or anything newer, including breaking major releases. Several conditions can be combined with commas, such as ">= 3.6, < 4.0". The lock file records the exact version chosen, so the constraint only matters when you deliberately upgrade.
Examples
version = "3.6.0" # exactlyversion = ">= 3.6, < 4.0"Related terms
- pessimistic constraint operator — The ~> version operator, which allows only the rightmost number you wrote to increase.
- dependency lock file — The .terraform.lock.hcl file that terraform init writes to record the exact provider versions chosen and their checksums.
- semantic versioning — A version numbering scheme of three numbers, major.minor.patch, raised for breaking changes, new features and fixes respectively.
- pinning — Fixing an exact version or digest of something you depend on so it cannot change without you noticing.
Taught in
- Providers And The required_providers Block — Infrastructure as Code with Terraform
- The Terraform Registry And Public Modules — Infrastructure as Code with Terraform
- Versioning And Pinning Modules — Infrastructure as Code with Terraform
- One Hour, No Weights Published — HashiCorp Terraform Associate (004) Exam Prep
- 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
- Where Modules Come From — HashiCorp Terraform Associate (004) Exam Prep
- Collaboration And Governance: Teams, Policies, Registry And Health — HashiCorp Terraform Associate (004) Exam Prep
- Trap Sprint: Twelve Answers That Are Almost True — HashiCorp Terraform Associate (004) Exam Prep