Terraform "no available provider ... matches the given constraints"
Terraform could not pick a provider version that satisfies every constraint at once. Your root module and a child module demand non-overlapping version ranges.
What this error means
terraform init fails because no provider version matches all constraints, listing the conflicting requirements from your config and modules. It is deterministic - the same config fails identically every time.
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider hashicorp/aws:
no available releases match the given constraints ">= 5.0.0, < 5.30.0", "~> 5.40"Common causes
Root and module constraints do not overlap
Your root required_providers pins ~> 5.40 while a child module requires < 5.30. No single version satisfies both, so the resolver fails.
An over-tight pin you added
A hard = 5.40.0 in one place conflicts with a wider range elsewhere. Loosening it to an overlapping range usually resolves the conflict.
How to fix it
Align the constraints to overlap
- Read which two constraints conflict in the error.
- Loosen your root pin to a range that overlaps the module requirement, or upgrade the module to one that accepts the newer provider.
- Prefer
~>pessimistic constraints over hard=so minor upgrades are allowed.
Inspect what each module requires
List the effective provider requirements across the configuration to find the source of the conflict.
terraform providers
terraform versionHow to prevent it
- Use
~>constraints rather than exact pins where possible. - Keep root and module provider constraints aligned when upgrading.
- Commit
.terraform.lock.hclso resolved versions are reproducible.