Reputation: 115
I have a single Service principle. Since my terraform code needs to access resources present in subscription A and B, how do i perform that, below is my provider block.
provider "azurerm" {
features {}
}
provider "azurerm" {
alias = "vnet"
subscription_id = "0000"
features {}
}
data "azurerm_private_dns_zone" "foo" {
provider = azurerm.vnet
name = var.private_dnszonename
resource_group_name = var.existing_dnsresourcegroup
}
Upvotes: 0
Views: 2640
Reputation: 28224
To allow us to create resources in multiple subscriptions, you could use multiple AzureRM providers by using aliases. You could also define SP authentication in your provider blocks. Then you can declare your resources in the specific provider.
For example, to create a resource group in that subscription with alias vnet
azurerm provider.
resource "azurerm_resource_group" "test" {
provider = "azurerm.vnet"
name = var.rgname
location = var.location
}
Read more details here.
Upvotes: 1