I created an Azure AI Search resource within the module az-search
, which works. Now within az-search/main.tf
, I am attempting to connect it to a virtual network and subnet, and create a private network for the Azure AI Search resource. So I am creating resources for azurerm_subnet
, azurerm_private_endpoint
, and azurerm_virtual_network
.
This is the error message I get when running terraform plan
:
To work with module.main.module.az-search.data.azurerm_subnet.search_subnet
│ its original provider configuration at
│ module.main.module.az-search.provider["registry.terraform.io/hashicorp/azurerm"].primarysubscription
│ is required, but it has been removed.
The same error message also shows for azurerm_private_endpoint
and azurerm_virtual_network
.
“primarysubscription” is my alias for the azurerm provider. This is within providers.tf
provider "azurerm" {
alias = "primarysubscription"
subscription_id = var.az_subscription_id
features {}
}
And I have azurerm as a required provider within my terraform.tf
as well as my az-search/terraform.tf
:
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.88.0"
}
...
}
When I run terraform providers
this is my output:
└── module.main
├── provider[registry.terraform.io/hashicorp/azurerm] >= 3.88.0
├── provider[registry.terraform.io/mastercard/restapi] >= 1.19.1
├── provider[registry.terraform.io/azure/azapi] ~> 1.7.0
├── module.adf
│ └── provider[registry.terraform.io/hashicorp/azurerm] >= 3.88.0
├── module.az-search
│ ├── provider[registry.terraform.io/mastercard/restapi] >= 1.19.1
│ ├── provider[registry.terraform.io/hashicorp/azurerm] >= 3.88.0
│ └── provider[registry.terraform.io/hashicorp/null]
└── module.cosmos
├── provider[registry.terraform.io/hashicorp/azurerm] >= 3.88.0
└── module.comosdb-mongo
└── provider[registry.terraform.io/hashicorp/azurerm] >= 3.3.0
So I do have hashicorp/azurerm provider in every module. Is there something I’m missing to get rid of the “Provider configuration not present” error?