How to fix Error: Duplicate required providers configuration - A module may have only one required providers configuration in Terraform

TerraformBEGINNERMEDIUMUpdated Dec 30, 2025ยท 193 views

Since Terraform 0.13, only one required_providers block is allowed per module. This error occurs when your configuration has multiple required_providers blocks. Consolidate them into a single block to resolve this issue.

Quick fix

Fixes Error: Duplicate required providers configuration - A module may have only one required providers configuration

# Search for all required_providers blocks
grep -r "required_providers" .
  1. Identify all required_providers blocks in your configuration
  2. Consolidate all provider requirements into a single block
  3. Remove the duplicate terraform blocks from other files
  4. If using modules, verify module provider configurations
terraform โ€” error
# Search for all required_providers blocks
grep -r "required_providers" .
Error: Duplicate required providers configuration - A module may have only one required providers configuration

What this error means

Terraform 0.13 introduced a restriction that prohibits multiple required_providers blocks within the same module. This change was made to prevent ambiguity when merging provider configurations from different files. Each module can only have one terraform block containing the required_providers configuration. If Terraform finds more than one, it will throw this error and halt the plan or apply operation. This is different from earlier Terraform versions where multiple terraform blocks were implicitly merged together. The restriction enforces a single source of truth for provider version constraints within each module.

Typical symptoms

  • Terraform plan or apply fails with the duplicate required providers error message
  • Error occurs even though your main configuration file only has one required_providers block
  • The error message indicates line numbers pointing to different configuration files
  • CI/CD pipelines fail during terraform init or plan stages

Common causes

  1. You have required_providers blocks defined in multiple files (e.g., versions.tf and providers.tf)
  2. A module you're using includes its own required_providers block that conflicts with your root module configuration
  3. You've split your terraform configuration across multiple files without consolidating provider requirements
  4. Upgrading from Terraform 0.12 to 0.13+ without consolidating existing required_providers blocks

How to fix "Error: Duplicate required providers configuration - A module may have only one required providers configuration"

1Identify all required_providers blocks in your configuration

Search your Terraform configuration directory for all occurrences of the required_providers block. This includes main files, versions.tf, providers.tf, and any other .tf files in the module.

bash
# Search for all required_providers blocks
grep -r "required_providers" .

Note the line numbers and files where required_providers appears. You should only have one per module.

2Consolidate all provider requirements into a single block

If you have required_providers in multiple files, choose one file to be your source of truth (usually versions.tf or main.tf) and move all provider declarations there.

Before (split configuration):

hcl
# versions.tf
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}
hcl
# providers.tf
terraform {
  required_providers {
    kubernetes = {
      source  = "hashicorp/kubernetes"
      version = "~> 2.0"
    }
  }
}

After (consolidated):

hcl
# versions.tf
terraform {
  required_version = ">= 0.13"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
    kubernetes = {
      source  = "hashicorp/kubernetes"
      version = "~> 2.0"
    }
  }
}

Then delete the terraform block from the other files.

3Remove the duplicate terraform blocks from other files

Delete any remaining terraform blocks containing required_providers from other configuration files. You can keep other terraform block settings like required_version in the main file if needed.

bash
# Example: if you consolidated into versions.tf, remove terraform block from providers.tf
# Edit providers.tf and remove or comment out the terraform block
4If using modules, verify module provider configurations

Modules are allowed to have required_providers blocks that declare their dependencies. However, make sure your root module doesn't duplicate these provider declarations.

Each module should declare its own provider requirements independently. The root module can then satisfy all constraints with a single version of each provider.

hcl
# Root module consolidates all requirements
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 4.0"  # Must satisfy all modules
    }
  }
}

module "networking" {
  source = "./modules/networking"
  # Module has its own required_providers block
}

module "database" {
  source = "./modules/database"
  # Module has its own required_providers block
}
5Run terraform init to validate the fix

After consolidating your configuration, run terraform init to reinitialize your working directory and verify the error is resolved.

bash
terraform init

If successful, you should see output indicating the Terraform configuration has been initialized without errors. You can then proceed with terraform plan and apply.

Advanced notes

Terraform Version Note: This restriction only applies to Terraform 0.13 and later. If you're still using Terraform 0.12, you can have multiple terraform blocks that will be implicitly merged. However, upgrading to 0.13+ is recommended for better module management and provider pinning.

Module Development Best Practices: When writing reusable modules, each module should declare its minimum required provider versions using >= constraints. This allows the root module to pin a single provider version that satisfies all module requirements. Avoid using exact version pins (~=) in modules unless absolutely necessary.

Provider Version Compatibility: When consolidating provider versions from multiple files, choose a version constraint that satisfies all module requirements. Use terraform plan without applying to verify compatibility before committing changes.

Frequently asked questions

What does "Error: Duplicate required providers configuration - A module may have" mean?
13 introduced a restriction that prohibits multiple required_providers blocks within the same module. This change was made to prevent ambiguity when merging provider configurations from different files. Each module can only have one terraform block containing the required_providers configuration.
How do I fix "Error: Duplicate required providers configuration - A module may have"?
Since Terraform 0.13, only one required_providers block is allowed per module. This error occurs when your configuration has multiple required_providers blocks. Consolidate them into a single block to resolve this issue.
What causes "Error: Duplicate required providers configuration - A module may have"?
You have required_providers blocks defined in multiple files (e.g., versions.tf and providers.tf) A module you're using includes its own required_providers block that conflicts with your root module configuration You've split your terraform configuration across multiple files without consolidating provider requirements
Is the "Error: Duplicate required providers configuration - A module may have" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading