Error: Provider configuration not present
Terraform’s “Provider configuration not present” error means a resource references a provider without a provider block, so Terraform cannot authenticate.
What It Means
Every Terraform resource belongs to a provider — AWS, Azure, Google Cloud, Kubernetes, etc. When you define a resource like aws_instance, Terraform expects an accompanying provider configuration. Without it, Terraform doesn’t know which region, credentials, or endpoint to use.
Why It Happens
- The
providerblock is missing from your configuration files. - The
required_providersblock is not set in theterraformblock. - You haven’t run
terraform initto download the provider plugin. - The provider version constraint conflicts with the installed version.
- The provider is specified in a module but not in the root configuration.
- A typo in the provider source or name.
How to Fix It
Step 1: Add a required_providers block
Every modern Terraform configuration should declare providers explicitly:
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}Step 2: Define the provider block
Add at least one provider block with the required configuration:
provider "aws" {
region = "us-east-1"
}For Kubernetes:
provider "kubernetes" {
config_path = "~/.kube/config"
}Step 3: Run terraform init
After adding provider declarations, download the provider plugins:
terraform initThis installs the provider versions specified in your required_providers block.
Step 4: Check provider version constraints
If you see a version-related error, verify your constraint allows the installed version:
terraform providersThis lists all required providers and their versions. Adjust the version constraint if needed:
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.0, < 6.0"
}
}Step 5: Verify provider configuration for modules
If you’re using a module that requires a provider, it must be configured in the root module. Add a providers block in the module call if the module uses provider aliases:
module "vpc" {
source = "./modules/vpc"
providers = {
aws = aws
}
}Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro