Skip to content

claranet/terraform-azurerm-vnet-peering

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure Virtual Network Peering

Changelog Notice Apache V2 License OpenTofu Registry

Terraform module to generate a Virtual Network Peering between two Virtual Networks which can belong to two different Azure Subscriptions.

Limitations

  • Peering between two virtual networks in different tenants isn't possible.

Global versioning rule for Claranet Azure modules

Module version Terraform version OpenTofu version AzureRM version
>= 8.x.x Unverified 1.8.x >= 4.0
>= 7.x.x 1.3.x >= 3.0
>= 6.x.x 1.x >= 3.0
>= 5.x.x 0.15.x >= 2.0
>= 4.x.x 0.13.x / 0.14.x >= 2.0
>= 3.x.x 0.12.x >= 2.0
>= 2.x.x 0.12.x < 2.0
< 2.x.x 0.11.x < 2.0

Contributing

If you want to contribute to this repository, feel free to use our pre-commit git hook configuration which will help you automatically update and format some files for you by enforcing our Terraform code module best-practices.

More details are available in the CONTRIBUTING.md file.

Usage

This module is optimized to work with the Claranet terraform-wrapper tool which set some terraform variables in the environment needed by this module. More details about variables set by the terraform-wrapper available in the documentation.

⚠️ Since modules version v8.0.0, we do not maintain/check anymore the compatibility with Hashicorp Terraform. Instead, we recommend to use OpenTofu.

module "azure_virtual_network" {
  source  = "claranet/vnet/azurerm"
  version = "x.x.x"

  environment    = var.environment
  location       = module.azure_region.location
  location_short = module.azure_region.location_short
  client_name    = var.client_name
  stack          = var.stack

  resource_group_name = module.rg.name

  cidrs       = ["10.10.0.0/16"]
  dns_servers = ["10.0.0.4", "10.0.0.5"] # Can be empty if not used
}

module "azure_vnet_peering" {
  source  = "claranet/vnet-peering/azurerm"
  version = "x.x.x"

  providers = {
    azurerm.src  = azurerm
    azurerm.dest = azurerm.preprod
  }

  src_virtual_network_id  = module.azure_virtual_network.id
  dest_virtual_network_id = var.virtual_network_id_dest

  src_forwarded_traffic_allowed  = true
  dest_forwarded_traffic_allowed = true

  src_virtual_network_access_allowed  = true
  dest_virtual_network_access_allowed = true
}

Providers

Name Version
azurecaf ~> 1.2.28
azurerm.dest ~> 4.0
azurerm.src ~> 4.0

Modules

No modules.

Resources

Name Type
azurerm_virtual_network_peering.dest resource
azurerm_virtual_network_peering.main resource
azurecaf_name.dst data source
azurecaf_name.src data source

Inputs

Name Description Type Default Required
dest_forwarded_traffic_allowed Controls if forwarded traffic from VMs in the remote virtual network is allowed. See documentation. bool false no
dest_gateway_transit_allowed Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network. See documentation. bool false no
dest_virtual_network_access_allowed Controls if the VMs in the remote virtual network can access VMs in the local virtual network. See documentation. bool false no
dest_virtual_network_id ID of the destination Virtual Network to peer. string n/a yes
dst_custom_name Custom name of the vnet peerings to create. string "" no
name_prefix Optional prefix for the generated name. string "" no
name_suffix Optional suffix for the generated name. string "to" no
src_custom_name Custom name of the vnet peerings to create. string "" no
src_forwarded_traffic_allowed Controls if forwarded traffic from VMs in the remote virtual network is allowed. See documentation. bool false no
src_gateway_transit_allowed Controls gatewayLinks can be used in the remote virtual network’s link to the local virtual network. See documentation. bool false no
src_virtual_network_access_allowed Controls if the VMs in the remote virtual network can access VMs in the local virtual network. See documentation. bool false no
src_virtual_network_id ID of the source Virtual Network to peer. string n/a yes
use_dest_remote_gateway Controls if remote gateways can be used on the local virtual network. See documentation. bool false no
use_src_remote_gateway Controls if remote gateways can be used on the local virtual network. See documentation. bool false no

Outputs

Name Description
dest_id Destination Virtual network peering id.
dest_name Destination Virtual network peering name.
id Source Virtual network peering id.
name Source Virtual network peering name.
resource Virtual network peering resource object.
resource_dest Destination Virtual network peering resource object.

Related documentation

Terraform resource documentation: terraform.io/docs/providers/azurerm/r/virtual_network_peering.html

Microsoft Azure documentation: docs.microsoft.com/en-us/azure/virtual-network/virtual-network-peering-overview