Terraform resource -> providers with count


It possible to configure provider for each resource with count?

I have this kind of code and I would like to create each reasource in other subscription (Azure)

resource "azurerm_virtual_network_peering" "net_2" {
  count = length(var.peerings_connections)
  name                      = var.peerings_connections[count.index].connection_name_spoke
  resource_group_name       = var.peerings_connections[count.index].resource_group_name_spoke
  remote_virtual_network_id = var.network_id_hub
  allow_forwarded_traffic   = var.peerings_connections[count.index].allow_forwarded_traffic
  allow_gateway_transit     = var.peerings_connections[count.index].allow_gateway_transit
  use_remote_gateways       = var.peerings_connections[count.index].use_remote_gateways
  virtual_network_name      = var.peerings_connections[count.index].virtual_network_name_spoke


No. You would need to have a different resource block for each provider (and that link is static - you can’t choose a provider based on a variable).

cool, thank you for response