Provider version mismatch — required_providers constraint conflict
Error: resource <type> requires version X.Y.Z but provider only has version A.B.C
Focused incident mode — strips away everything but this runbook.
Symptoms
- Error: resource <type> requires version X.Y.Z but provider only has version A.B.C
- terraform init downloads an incompatible provider version
- Module upgrade fails with provider constraint conflict
Evidence to grab
Collect these artifacts before you change anything — they prove (or rule out) each cause.
Required providers block
grep -A5 'required_providers' *.tfCurrently installed provider versions
terraform version
Diagnostic flow
Run the steps in order, marking each claim confirmed or refuted. The evidence you gather feeds the ranked causes below.
Guided decision tree is ready.
Steps with commands, expected output, and pass/fail branches.
Ranked root causes
Evidence checklist
- A module requires >=4.0 but root requires ~>3.0
- terraform init shows 'provider version conflict'
Confirm before fixing
grep -r 'required_providers' --include='*.tf' .Find all required_providers declarations
Fix
terraform init -upgradeRe-resolve and upgrade provider versions to satisfy all constraints
Expected: Upgraded provider to the latest compatible version
Resolution runbook
Apply from top to bottom after the cause is confirmed. Review every command before running it — risk tags are shown on each.
terraform providersShow all provider constraints and installed versions
grep -r 'required_providers' --include='*.tf' .Find all version constraints in the module tree
terraform init -upgradeUpgrade providers to satisfy all constraints
terraform providers lock -platform=linux_amd64 -platform=darwin_arm64Re-lock providers for the target platforms
Prevention
- Pin provider versions with ~> constraints in required_providers.
- Commit .terraform.lock.hcl to version control for reproducible installs.
- Run terraform init -upgrade in CI when modules are updated.
- Use terraform providers lock to pin across multiple platforms.
Related runbooks
Same stack, same failure family — worth a skim.
Backend initialization required: please run "terraform init"
Failed to request access to registry.terraform.io
Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.