Skip to content

data-platform-hq/terraform-azurerm-peering

Repository files navigation

Azure virtual network peering Terraform module

Terraform module for peering establishment between two virtual networks

Usage

This module is provisioning peering between two virtual networks. Below is an example that provisions two virtual networks and peering between them.

module "vpc_src" {
  source  = "data-platform-hq/network/azurerm"

  project        = "my_project"
  env            = "test"
  location       = "westeurope"
  resource_group = "test_group"
  cidr           = ["10.0.3.0/24"]
}

module "vpc_dst" {
  source  = "data-platform-hq/network/azurerm"

  project        = "my_project"
  env            = "dev"
  location       = "westeurope"
  resource_group = "dev_group"
  cidr           = ["172.16.0.0/16"]
}

module "peering" {
  source  = "data-platform-hq/peering/azurerm"

  src_peering_name             = module.vpc_dst.name
  src_resource_group_name      = "test_group"
  src_virtual_network_name     = module.vpc_scr.name
  src_virtual_network_id       = module.vpc_scr.id

  dst_peering_name             = module.vpc_scr.name
  dst_resource_group_name      = "dev_group"
  dst_virtual_network_name     = module.vpc_dst.name
  dst_virtual_network_id       = module.vpc_dst.id

  allow_virtual_network_access = true
  allow_forwarded_traffic      = true
  allow_gateway_transit        = false
  use_remote_gateways          = false
}

Requirements

Name Version
terraform >= 1.0.0
azurerm >= 4.0.1

Providers

Name Version
azurerm >= 4.0.1

Modules

No modules.

Resources

Name Type
azurerm_virtual_network_peering.dst resource
azurerm_virtual_network_peering.src resource

Inputs

Name Description Type Default Required
allow_forwarded_traffic Controls if forwarded traffic from VMs in the remote virtual network is allowed bool false no
allow_gateway_transit Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network bool false no
allow_virtual_network_access Controls if the VMs in the remote virtual network can access VMs in the local virtual network bool true no
dst_peering_name The name of the virtual network peering in destination VPC string n/a yes
dst_resource_group_name The name of the resource group in which to create the virtual network peering string n/a yes
dst_virtual_network_id The full Azure resource ID of the destination virtual network string n/a yes
dst_virtual_network_name The name of the destination virtual network string n/a yes
src_peering_name The name of the virtual network peering in source VPC string n/a yes
src_resource_group_name The name of the resource group in which to create the virtual network peering string n/a yes
src_virtual_network_id The full Azure resource ID of the source virtual network string n/a yes
src_virtual_network_name The name of the source virtual network string n/a yes
use_remote_gateways Controls if remote gateways can be used on the local virtual network bool false no

Outputs

Name Description
dst_peering_name_to_id_map Map of DST peering name to ID
src_peering_name_to_id_map Map of SRC peering name to ID

License

Apache 2 Licensed. For more information please see LICENSE