Skip to content
Latchkey

Terraform "Duplicate provider configuration" in CI

A module declares two provider blocks for the same provider without distinct aliases -- two default configurations, or two blocks with the same alias -- which Terraform forbids.

What this error means

validate/init fails with "Duplicate provider configuration", naming the provider. It surfaces after merging files that each declared the provider, or copy-pasting a block without changing the alias.

terraform
Error: Duplicate provider configuration

  on providers.tf line 8:
   8: provider "aws" {

A default (non-aliased) provider configuration for "aws" was already given at
providers.tf:1,1-16. If multiple configurations are required, set the "alias"
argument for alternative configurations.

Common causes

Two default provider blocks

Only one non-aliased provider block per provider is allowed in a module; a second default block collides.

Two blocks sharing an alias

Aliases must be unique per provider; two blocks with alias = "west" collide.

How to fix it

Keep one default and alias the rest

Merge duplicate defaults into one block, and give additional configurations distinct aliases.

providers.tf
provider "aws" {
  region = "us-east-1"
}

provider "aws" {
  alias  = "west"
  region = "us-west-2"
}

How to prevent it

  • Declare provider blocks in one place per module.
  • Use a unique alias for every additional provider configuration.
  • Run validate after merging branches that touch providers.

Frequently asked questions

What causes ""Duplicate provider configuration""?
Only one non-aliased provider block per provider is allowed in a module; a second default block collides.
How do I fix "Duplicate provider configuration"?
Merge duplicate defaults into one block, and give additional configurations distinct aliases.

Related guides

References

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