hashicorp/terraform · error

failed to determine the configuration's provider requirement

Error message

failed to determine the configuration's provider requirements: %s

What it means

Emitted by Config.VerifyDependencySelections when c.ProviderRequirements() returns diagnostics with errors while building the merged set of provider version constraints. The code comments note this is an edge case: the config loader parses version-constraint strings slightly differently than the requirements resolver, so a constraint that loaded fine can still fail here. Hit by every command that checks locked dependencies (plan/apply/validate/destroy) after init.

Source

Thrown at internal/configs/config.go:271

// It's typically the responsibility of "terraform init" to change the locked
// dependencies to conform with the configuration, and so
// VerifyDependencySelections is intended for other commands to check whether
// it did so correctly and to catch if anything has changed in configuration
// since the last "terraform init" which requires re-initialization. However,
// it's up to the caller to decide how to advise users recover from these
// errors, because the advise can vary depending on what operation the user
// is attempting.
func (c *Config) VerifyDependencySelections(depLocks *depsfile.Locks) []error {
	var errs []error

	reqs, diags := c.ProviderRequirements()
	if diags.HasErrors() {
		// It should be very unusual to get here, but unfortunately we can
		// end up here in some edge cases where the config loader doesn't
		// process version constraint strings in exactly the same way as
		// the requirements resolver. (See the addProviderRequirements method
		// for more information.)
		errs = append(errs, fmt.Errorf("failed to determine the configuration's provider requirements: %s", diags.Error()))
	}

	for providerAddr, constraints := range reqs {
		if !depsfile.ProviderIsLockable(providerAddr) {
			continue // disregard builtin providers, and such
		}
		if depLocks != nil && depLocks.ProviderIsOverridden(providerAddr) {
			// The "overridden" case is for unusual special situations like
			// dev overrides, so we'll explicitly note it in the logs just in
			// case we see bug reports with these active and it helps us
			// understand why we ended up using the "wrong" plugin.
			log.Printf("[DEBUG] Config.VerifyDependencySelections: skipping %s because it's overridden by a special configuration setting", providerAddr)
			continue
		}

		var lock *depsfile.ProviderLock
		if depLocks != nil { // Should always be true in main code, but unfortunately sometimes not true in old tests that don't fill out arguments completely
			lock = depLocks.Provider(providerAddr)

View on GitHub (pinned to c9def3e214)

Solutions

  1. Re-run `terraform init`; init surfaces the exact constraint that failed to parse.
  2. Audit every required_providers block in the module tree for malformed version strings (use `terraform providers` to list them).
  3. Simplify/standardize constraint syntax (e.g. `~> 1.2`, `>= 1.2.0, < 2.0.0`) and avoid prerelease operators unless the provider publishes them.
  4. If a specific module is at fault, run `terraform -chdir=<module> init` in isolation to localize it.

Example fix

// before
terraform {
  required_providers {
    aws = { source = "hashicorp/aws" version = "=> 1.0" }  // typo: =>
  }
}

// after
terraform {
  required_providers {
    aws = { source = "hashicorp/aws" version = ">= 1.0" }
  }
}
Defensive patterns

Strategy: validation

Validate before calling

// In CI, run `terraform init` (it performs the same ProviderRequirements parse)
// before plan/apply so a malformed constraint fails fast with the offending string.
// Optionally lint each constraint with hclversion-style parsing in a pre-merge check.

Prevention

When it happens

Trigger: Calling VerifyDependencySelections against a config tree whose required_providers blocks contain a version constraint string ProviderRequirements cannot resolve: malformed comparator (e.g. `=>`), unsupported prerelease syntax, duplicate provider addresses with conflicting constraints, or an unparseable constraint introduced by a module update.

Common situations: Editing required_providers with a typo'd constraint, mixing source addresses for the same local name across modules, a module upgrade introducing an unusual constraint operator, or a prerelease constraint the resolver rejects.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/79b01f1f9a5b87fd. Report an issue: GitHub.