Error
Initializing the backend…
Terraform encountered problems during initialisation, including 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 providers.tf line 15, in terraform:
│ 15: required_providers {
│
│ A module may have only one required providers configuration. The required providers were previously configured at
│ providers.tf:2,3-21.
╵
╷
│ Error: Duplicate required providers configuration
│
│ on providers.tf line 15, in terraform:
│ 15: required_providers {
│
│ A module may have only one required providers configuration. The required providers were previously configured at
│ providers.tf:2,3-21.
╵
Answer
YOU SHOULD NOT HAVE MORE THAN TWO “terraform” block in terraform code
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.17.0"
}
azurerm = {
source = "hashicorp/azurerm"
version = "3.73.0"
}
github = {
source = "integrations/github"
version = "5.37.0"
}
}
}
provider "aws" {
# Configuration options
}
provider "azurerm" {
# Configuration options
}
provider "github" {
# Configuration options
}
- SonarQube Error: Error status returned by url [https://api.sonarcloud.io - September 5, 2024
- AWS SES Errors and Solution - September 2, 2024
- SRE Foundation Certification - August 29, 2024
I also faced the same issue. The simple solution to create override file and add all other provider config on that file so during initialization it will merge the config.
provider.tf
==
provider “aws” {
region = var.region
}
==
provider_override.tf
==
terraform {
required_providers {
kubectl = {
source = “gavinbunney/kubectl”
version = “>= 1.14.0”
}
helm = {
source = “hashicorp/helm”
version = “>= 2.6.0”
}
}
required_version = “~> 1.0”
}
==