I’m trying to author a Terraform module that will be able to manage resources in two different “configurations” of the same provider but am unable to declare those configurations in the required_providers
block.
This leads to the message:
Provider hashicorp/azurerm with the local name “az” was previously required as “log”. A provider can only be required once within required_providers.
E.g. Extract from sample code available:
main.tf
terraform {
backend "azurerm" {}
}
provider "azurerm" {
features {}
alias = "az"
subscription_id = var.subscription_id
tenant_id = var.tenant_id
}
provider "azurerm" {
features {}
alias = "log"
subscription_id = var.subscription_id
tenant_id = var.tenant_id
}
resource "azurerm_resource_group" "main" {
name = "rg-main"
location = "West Europe"
provider = azurerm.az
}
module "module" {
source = "./modules/module"
providers = {
az = azurerm.az
log = azurerm.log
}
}
./modules/module/main.tf
terraform {
required_providers {
az = { source = "hashicorp/azurerm" }
log = { source = "hashicorp/azurerm" }
}
}