Terraform-provider-azurerm: virtual network peering between different azure subscription

Created on 15 Aug 2017  ·  9Comments  ·  Source: terraform-providers/terraform-provider-azurerm

Hi,
In our scenario we have different subscriptions with vnets that should be peered together.
Currently this is possible via a manual process described here:
https://docs.microsoft.com/en-us/azure/virtual-network/create-peering-different-subscriptions

Is this use case of peering different subscription is currently also supported by TF ?
https://www.terraform.io/docs/providers/azurerm/r/virtual_network_peering.html

if not , are there any plans to include this feature in the future?

Thanks,
Alex

question

All 9 comments

Hey @alexwo

From what I can see in the documentation across those two pages - this should be possible in Terraform. Using the examples in the PowerShell this should be possible with the following Terraform Configuration:

variable "remote_virtual_network_id" {}

resource "azurerm_resource_group" "test" {
  name     = "peeredvnets-rg"
  location = "West US"
}

resource "azurerm_virtual_network" "test1" {
  name                = "peternetwork1"
  resource_group_name = "${azurerm_resource_group.test.name}"
  address_space       = ["10.0.1.0/24"]
  location            = "${azurerm_resource_group.test.location}"
}

resource "azurerm_virtual_network_peering" "test1" {
  name                      = "peer1to2"
  resource_group_name       = "${azurerm_resource_group.test.name}"
  virtual_network_name      = "${azurerm_virtual_network.test1.name}"
  remote_virtual_network_id = "${var.remote_virtual_network_id}"
  allow_virtual_network_access  = true
}

Would it be possible to take a look and see if that solves your issue?

Thanks!

Thanks for the quick response!
seems equivalent to power shell declaration, will try that and update if everything worked well

👋 hey @alexwo - did you manage to set up the peering between the two networks in the end? :) Thanks!

ping @alexwo :)

Hi tombuildsstuff,
We still did not have a chance to actually test this out. Currently I'm booked with other tasks :)
I can update once we actually try this out but not sure when..

@alexwo no worries - thanks for letting us know :)

Hi,
wanted to confirm that this worked well for us.

Thanks,
Alex

@alexwo that's great to hear, thanks for confirming :)

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings