Skip to content
Latchkey

Terraform "provider ... not present in required_providers"

A resource references a provider that is not declared in required_providers. Modern Terraform will not silently guess the source - every provider must be explicitly declared.

What this error means

terraform init fails because a provider used by a resource or module is not present in required_providers, or warns that an implicit provider source was assumed. It surfaces after adding a resource from an undeclared provider.

terraform init output
Error: Provider requirements cannot be satisfied

Provider "registry.terraform.io/hashicorp/random" is not present in the
configuration's required_providers block, but is required by module "naming".

Common causes

Provider used but never declared

A resource (e.g. random_id) implies a provider that no required_providers block declares, so Terraform cannot resolve its source.

Module needs a provider the root did not pass

A child module requires a provider the root configuration neither declares nor passes through, breaking provider resolution.

How to fix it

Declare the provider explicitly

Add every provider you use to a required_providers block with its source and a version constraint.

versions.tf
terraform {
  required_providers {
    aws    = { source = "hashicorp/aws", version = "~> 5.40" }
    random = { source = "hashicorp/random", version = "~> 3.6" }
  }
}

Pass providers into modules

When a module needs a provider configuration, pass it explicitly with a providers argument.

main.tf
module "naming" {
  source    = "./modules/naming"
  providers = { random = random }
}

How to prevent it

  • Declare all providers in a versions.tf required_providers block.
  • Run terraform validate in CI to catch undeclared providers early.
  • Pass providers explicitly to modules that need them.

Frequently asked questions

What causes "provider not declared"?
A resource (e.g. random_id) implies a provider that no required_providers block declares, so Terraform cannot resolve its source.
How do I fix provider not declared?
Add every provider you use to a required_providers block with its source and a version constraint.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card