Terraform Error Guide: 'Unsupported Terraform Core version' — align the required_version constraint
Fix 'Unsupported Terraform Core version' in Terraform: reconcile the required_version constraint with the CLI you run locally and in CI, pin versions with tfenv, and avoid split-brain toolchains.
- #terraform
- #iac
- #troubleshooting
- #errors
Fixing errors like this? Get 500 free DevOps AI prompts
500 copy-paste AI prompts for the stack you actually run — one PDF, free.
Overview
Terraform refuses to run when the CLI version does not satisfy the required_version constraint declared in the configuration. It fails before any plan or apply:
Error: Unsupported Terraform Core version
on versions.tf line 2, in terraform:
2: required_version = ">= 1.7.0"
This configuration does not support Terraform version 1.6.2. To proceed,
either choose another supported Terraform version or update the root module's
version constraint. Version constraints are normally set for good reason, so
updating the constraint may lead to other errors or unexpected behavior.
The constraint lives in the terraform {} block. When the CLI on the machine (or CI runner) falls outside that range — too old or, with a pinned upper bound, too new — Terraform stops immediately. This is a guardrail, not a bug: the config author decided which core versions are safe.
Symptoms
terraform init,plan, orvalidateaborts instantly withUnsupported Terraform Core version.- The error names a specific line in
versions.tf(or wherever theterraform {}block lives) and the CLI version in use. - It works on one engineer’s laptop but fails in CI, or vice versa — a classic version split-brain.
- A previously green pipeline breaks right after someone bumped
required_versionor upgraded the runner image. - Child modules with stricter constraints fail even though the root module would pass.
Common Root Causes
- CLI older than the lower bound — config requires
>= 1.7.0, the runner ships1.6.2. - CLI newer than a pinned upper bound — config pins
~> 1.5.0and the machine has1.7.x. - CI image drift — the pipeline uses
hashicorp/terraform:latest(or a cached image) that no longer matches the constraint someone just tightened. - A child module’s constraint is stricter than the root;
initsurfaces the tightest one. - Mixed local toolchains — engineers on different tfenv/asdf versions with no
.terraform-versionpin. - OpenTofu vs Terraform confusion — running
tofuagainst a config that constrains Terraform core, or the reverse.
Diagnostic Workflow
First, see exactly which version you are running and where the binary comes from:
terraform version
which terraform
Find every constraint in play — the root and any modules:
grep -rn "required_version" .
Inspect the offending block. The constraint operator matters:
terraform {
required_version = ">= 1.7.0, < 2.0.0" # too new AND too old both fail
}
If you use tfenv, list and pin an installed version that satisfies the range:
tfenv list
tfenv install 1.7.5
tfenv use 1.7.5
Confirm the child-module constraints, since init enforces the strictest:
terraform init
# reads all modules; reports the tightest required_version violation
If CI is the failing surface, pin the image tag instead of latest:
# .gitlab-ci.yml (or equivalent) — pin, do not float
# image: hashicorp/terraform:1.7.5
Example Root Cause Analysis
A team upgraded their module registry release and set required_version = ">= 1.7.0" to use a new function. Local applies worked because the authors were on 1.7.5. The nightly drift-detection pipeline broke with Unsupported Terraform Core version ... version 1.6.2.
The pipeline used a cached hashicorp/terraform:1.6 image baked months earlier. The fix was two parts: pin the CI image to hashicorp/terraform:1.7.5 to match the new floor, and add a .terraform-version file so tfenv keeps every laptop on the same core. After both, terraform version reported 1.7.5 everywhere and the constraint passed. The lesson: a required_version bump is a toolchain change, and every place that runs Terraform must be upgraded in lockstep.
Prevention Best Practices
- Pin the CI image to an exact tag (
hashicorp/terraform:1.7.5), neverlatest. - Commit a
.terraform-versionfile so tfenv/asdf keep laptops aligned automatically. - Use a range, not a hard pin, in reusable modules (
>= 1.7.0) so consumers are not boxed in, but pin exact versions in leaf/root configs. - Bump
required_versionand every runner in the same PR, so the constraint and the toolchain move together. - Run
terraform versionas the first CI step to make the running version obvious in logs. - Keep root and module constraints compatible — audit them when upgrading.
Quick Command Reference
terraform version # what CLI is actually running
which terraform # where the binary comes from
grep -rn "required_version" . # every constraint in the tree
tfenv list # installed versions
tfenv install 1.7.5 && tfenv use 1.7.5 # install + switch
echo "1.7.5" > .terraform-version # pin the repo's core version
terraform init # enforces the strictest module constraint
Conclusion
Unsupported Terraform Core version is a version-alignment problem, not a code problem: the CLI you ran does not satisfy the required_version constraint the configuration declares. Read the constraint, check terraform version, and bring the toolchain into range — ideally by pinning both the CI image and a .terraform-version file so local and CI can never drift apart. Resist the urge to loosen the constraint blindly; it was set deliberately, and widening it can trade one clean error for subtler runtime failures.
Get 500 Battle-Tested DevOps AI Prompts — Free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.