Skip to main content
In this guide, you’ll learn how to enforce Terraform and Terragrunt version constraints directly within your Terragrunt configuration. By pinning approved versions of the binaries, you’ll avoid unexpected upgrades and ensure consistency across your infrastructure deployments.
The image illustrates the benefits and considerations of using terraform_version_constraint and terragrunt_version_constraint attributes, highlighting version limitations and compatibility with setting constraints.

Why Version Constraints?

Use version constraints to:
  • Guarantee compatibility with existing state and modules
  • Prevent accidental upgrades during CI/CD runs
  • Enforce organizational compliance on approved tool versions
Always review your infrastructure modules and provider versions before updating constraints to avoid breaking changes.

Key Attributes

Terraform Version Constraint Example

Below is a terragrunt.hcl snippet that requires Terraform 1.8.4:
When a non-matching Terraform binary is detected, Terragrunt exits with an error:
To proceed, you can update or comment out the constraint to match your installed version:

Terragrunt Version Constraint Example

To restrict the Terragrunt binary, add terragrunt_version_constraint. The following example allows any version greater than 0.58.0 and up to 0.58.11:
When your local Terragrunt is outside the specified range, all commands will fail:
Locking to very specific versions can block legitimate upgrades. Plan your version bumps carefully and test in a staging environment.

Watch Video