Can i data source 2 resource groups with azure in the same main

Closed. This question needs details or clarity. It is not currently accepting answers.


Add details and clarify the problem you’re solving. This will help others answer the question. You can edit the question or post a new one.

Closed 12 hours ago.

can I data source two existing resource groups? I want to use a shared route table that resides in another resource group. I tried to source both but I am having trouble. am I wrong?

It’s not clear what you are asking but it sounds like you need to fetch the data for two existing resource groups.

You can just use two data blocks for this:

data "azurerm_resource_group" "ResourceGroupA" {
  name = "resource-group-a"
}

data "azurerm_resource_group" "ResourceGroupB" {
  name = "resource-group-b"
}

And then reference them using:

data.azurerm_resource_group.ResourceGroupA.x data.azurerm_resource_group.ResourceGroupB.x