The below sample is given to give an idea about the question.
I have a resource group and EventHubNS created in the root module of the Terraform script
I have another module , called processingmodule ,that has function, EventHub and few other aggregated components.
So the Root module is as below - Create Azure Resource Group Create EventHubNS Create processingModule
If the event hub was created in the root module, the eventhub resource is created using below resource block
resource "azurerm_eventhub" "eventhub" {
name = "${var.eventhubname}-eh"
namespace_name = azurerm_eventhub_namespace.eventhubns.name
resource_group_name = azurerm_resource_group.RG.name
partition_count = var.eventhub_partitioncount
message_retention = 5
}
If I write the module, the namespace_name and resource_group_name cannot be referred as shown below
namespace_name = azurerm_eventhub_namespace.eventhubns.name
resource_group_name = azurerm_resource_group.RG.name
Instead, the namespace_name should be referred through variable.
namespace_name = var.eventhubnsname
resource_group_name = var.resourcegroupname
So question is - is there anyway to refer to the resources created in the root module from the processingcomponent module