Learn to enforce Terraform and Terragrunt version constraints in your configuration to ensure consistency and avoid unexpected upgrades.
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.
When a non-matching Terraform binary is detected, Terragrunt exits with an error:
Copy
Ask AI
~/workspace/vpc > terragrunt planERROR[0000] The currently installed version of Terraform (1.9.0) is not compatible with the version Terragrunt requires (= 1.8.4).ERROR[0000] Unable to determine underlying exit code, so Terragrunt will exit with error code 1
To proceed, you can update or comment out the constraint to match your installed version:
Copy
Ask AI
# terraform_version_constraint = "= 1.8.4"
Copy
Ask AI
~/workspace/vpc > terragrunt planaws_vpc.this[0]: Refreshing state... [id=vpc-0d98d39c5a645c65f]aws_default_security_group.this[0]: Refreshing state... [id=sg-0617b0ec3422dbc5]No changes. Your infrastructure matches the configuration.
When your local Terragrunt is outside the specified range, all commands will fail:
Copy
Ask AI
~/workspace/vpc > terragrunt -versionterragrunt version v0.58.12~/workspace/vpc > terragrunt planERROR[0000] The currently installed version of Terragrunt (0.58.12) is not compatible with the version Terragrunt requires (> 0.58.0, <= 0.58.11).ERROR[0000] Unable to determine underlying exit code, so Terragrunt will exit with error code 1
Locking to very specific versions can block legitimate upgrades. Plan your version bumps carefully and test in a staging environment.