establish peering between non-terraform VNET with terraform VNET

Samrat Basra 20 Reputation points
2024-08-08T13:05:42.87+00:00

can we establish peering between non-terraform VNET with terraform VNET.

can someone please share at least the manual steps and required permission as well.

Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,463 questions
{count} votes

Accepted answer
  1. Iheanacho Chukwu 1,015 Reputation points
    2024-08-10T10:48:15.7666667+00:00

    As mentioned by Isaac Ineh-dumbi, please confirm the network contributor access is given for 2 networks to be peered.

    Contributor or Network Contributor role on both VNets (for creating peering).

    The issue is related to the inability to sync address spaces between the VNets, as pointed out by the error, due not having the required Network Contributor access to the other virtual Network.

    1 peerings are unable to connect to all the address spaces in this virtual network and must be synced. You must have contributor access to the peered virtual network to sync the virtual networks.

    Please ensure that peering is configured in both directions, preferably via code, chek the sample code Deploy Azure Virtual Network Peering with a Terraform Module and also check that Network Contributor permissions are granted on both VNets.

    1 person found this answer helpful.

7 additional answers

Sort by: Most helpful
  1. Gary Clarke 0 Reputation points
    2024-08-08T23:02:39.6333333+00:00

    Certainly! Establishing peering between non-Terraform-managed virtual networks (VNets) and Terraform-managed VNets in Azure is possible. Let's break down the steps:

    1. Manual Steps:
      • Non-Terraform VNet:
        • In the Azure portal, navigate to the non-Terraform VNet.
        • Go to Settings > Peerings.
        • Click Add to create a new peering.
        • Specify the VNet to peer with(the Terraform-managed VNet).
        • Configure the peering options (e.g., allow forwarded traffic, gateway transit, etc.).
        • Click OK to create the peering.
      • Terraform-Managed VNet:
        • Define the VNet peering in your Terraform configuration using the azurerm_virtual_network_peering resource.
        • Specify the remote_virtual_network_id (the non-Terraform VNet's ID).
        • Set the appropriate properties (e.g., allow_forwarded_traffic, use_remote_gateways, etc.).
    2. Required Permissions:
      • Ensure that the service principal or user account used by Terraform has the necessary permissions:
        • Contributor or Network Contributor role on both VNets (for creating peering).
        • Reader role on the non-Terraform VNet (to retrieve its details in Terraform).
    0 comments No comments

  2. Samrat Basra 20 Reputation points
    2024-08-09T11:46:51.4066667+00:00

    ok i created one fresh VNET with terraform and tried to establish peering with existing non-terrafrom VNET and got this error message:

    1 peerings are unable to connect to all the address spaces in this virtual network and must be synced. You must have contributor access to the peered virtual network to sync the virtual networks.

    Am I missing any permission on existing non-terraform VNET ?

    0 comments No comments

  3. Samrat Basra 20 Reputation points
    2024-08-09T14:29:04.8966667+00:00

    here is the screenshot as well:
    User's image

    0 comments No comments

  4. Isaac Ineh-dumbi 0 Reputation points
    2024-08-09T17:16:04.9166667+00:00

    The error message you encountered indicates that the peering between your Terraform-created VNET and the existing non-Terraform VNET lacks the necessary permissions to synchronize the virtual networks.

    Please verify that you have the required permissions to sync the virtual networks. You will need at least Network Contributor permissions for both VNETs. This also applies to virtual networks in different subscriptions or EntraID tenants. To assign the Network Contributor role, follow these steps:

    • Navigate to the Azure portal.
    • Go to the Access control (IAM) section for your subscription or resource group.
    • Add yourself or the relevant user/service principal as a Network Contributor to both the source and destination virtual networks. You can refer to this guide for more details: Role Assignments in the Azure Portal.

    I hope this information is helpful! If you encounter any further issues, please feel free to ask for additional assistance and share the configuration code snippet! 😊👍


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.