terraform dependency_error ai_generated true

Error: Module version requirements have changed: version constraint not met

ID: terraform/tf-module-version-mismatch

Also available as: JSON · Markdown
88%Fix Rate
90%Confidence
65Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1 active

Root Cause

Module version specified in configuration does not match available versions in the registry.

generic

Workarounds

  1. 90% success Check available versions in the registry and update the version constraint
    Visit registry.terraform.io for the module, update version = "~> X.Y" in the module block

    Sources: https://developer.hashicorp.com/terraform/language/modules/syntax

  2. 85% success Run terraform init -upgrade to fetch the latest matching version
    terraform init -upgrade will re-evaluate version constraints and download compatible versions

    Sources: https://developer.hashicorp.com/terraform/cli/commands/init

Dead Ends

Common approaches that don't work:

  1. Pin to a specific commit hash of a registry module 80% fail

    Terraform Registry modules are versioned by semver tags, not commit hashes; this only works for git sources

  2. Remove the version constraint entirely 65% fail

    Without version constraints, terraform init may pull breaking changes from newer module versions

Error Chain

Frequently confused with: