How to call a resource from different subscription?

We need to send diagnostics to a log analytics workspace in a different subscription, however the data block doesnt let us specify the subscrition ID. If anyone has ever done this and can share the solution, it will be much appreciated.

1 Like

hi,

example in our main.tf :

subscription 1

provider “azurerm” {
version = “~> 2.11.0”
features {}
subscription_id = SUB_ID
}

transversal subscription

provider “azurerm” {
version = “~> 2.11.0”
alias = transversal
features {}
subscription_id = TRANSVERSAL_SUB_ID
}

AND in your ressource (example) :

data “azurerm_key_vault” “mgmt” {
provider = azurerm.transversal
name = “{var.mgmt_key_vault_name}" resource_group_name = "{var.mgmt_resource_group_name}”
}

1 Like

I am also having that same issue.
Did you manage to resolve it?

I was able to achieve it by declaring a provider for the other subscription (log analytics workspace) and then reference it to direct the logs to it.