terraform,

Resolve Terraform's 'Error: Duplicate required providers configuration'

Apr 03, 2023 · 1 min read · Post a comment

Another not so common error that I’ve faced while working on a Terraform module:

Initializing modules...
There are some problems with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.
╷
│ Error: Duplicate required providers configuration
│
│   on requirements.tf line 2, in terraform:
│    2:   required_providers {
│
│ A module may have only one required providers configuration. The required providers were previously configured at providers.tf:2,3-21.
╵

The error goes way back in TF version 0.13 as a breaking change that allows only one required_providers block per module.

Prerequisites

  • Terraform

Solution

Two things to try:

  • Check that you have the required_providers configuration at one place, in a file. A single source of truth, if possible.
  • Update to the latest TF version.

Conclusion

When nothing works, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.