Search

Please login in for more filter options


Kickstart your project with AVM templates.

network-virtualnetwork

report
Report Package network-virtualnetwork

If you believe that this package or its contents contain harmful information, please inform us.
Please be aware that we will never share your credentials.

Please let us know what this package contains.
Please enter a valid email address.

This Terraform Azure Verified Module deploys: terraform-azurerm-avm-res-network-virtualnetwork

ipm add --package avm-terraform/network-virtualnetwork --version 0.22.2 

Published: 29-08-2026

Project URL: https://ipmhub.io/avm-terraform

Package Type: Terraform

License: MIT


Azure Virtual Network Module

This module is used to manage Azure Virtual Networks, Subnets and Peerings, with optional IPAM (IP Address Management) support.

This module is composite and includes sub modules that can be used independently for pre-existing virtual networks. These sub modules are:

  • subnet - The subnet module is used to manage subnets within a virtual network.
  • peering - The peering module is used to manage virtual network peerings.

Features

This module supports managing virtual networks and their associated subnets and peerings together or independently.

The module supports:

  • Creating a new virtual network
  • Creating a new subnet
  • Creating a new virtual network peering
  • Associating DNS servers with a virtual network
  • Associating a DDOS protection plan with a virtual network
  • Associating a network security group with a subnet
  • Associating a route table with a subnet
  • Associating a service endpoint with a subnet
  • Associating a virtual network gateway with a subnet
  • Assigning delegations to subnets
  • IPAM pool allocation for virtual network address space
  • IPAM pool allocation for individual subnets
  • Choice of IPAM or traditional static addressing per virtual network

IPAM Support

This module provides comprehensive IPAM (IP Address Management) support through Azure Virtual Network Manager IPAM pools.

What IPAM Provides

  • VNet address space allocation from centralized IPAM pools
  • Subnet address allocation from IPAM pools
  • Dual-stack support - one IPv4 pool and one IPv6 pool per virtual network
  • All standard subnet features work with IPAM subnets (NSGs, service endpoints, delegations, etc.)

Benefits

  • Centralized IP governance through Azure Network Manager
  • Automatic conflict prevention during address allocation
  • Simplified address management across multiple deployments

IPAM Regional Support

⚠️ IPAM NOT supported in these regions: chilecentral, jioindiawest, malaysiawest, qatarcentral, southafricawest, westindia, westus3

Note: IPAM is available in all other regions where Azure Virtual Network Manager is supported. For the most up-to-date regional availability, consult the Azure products by region page.

IPAM Examples

IPAM Allocation Rules and Sizing

Address space is requested from an IPAM pool as a single allocation per pool. The following are enforced by the Azure Resource Provider (they are platform rules, not module limitations):

Rule Detail
One pool per IP type At most one IPv4 pool and one IPv6 pool per virtual network.
No duplicate pools The same pool cannot be referenced more than once on a VNet or subnet.
No IPAM + static mix A virtual network uses either IPAM pools or a static address_space, not both.
Subnet pools are a subset A subnet may only reference pools that its virtual network already uses.

Sizing: set the size on the single pool entry using either number_of_ip_addresses (for example "256") or prefix_length (for example 24). To request more address space from a pool, increase that value - do not add a second entry for the same pool.

Resolved prefixes (summarization vs. fragmentation): Azure resolves one allocation into one or more CIDR blocks. Contiguous free space is summarized into a single larger prefix (for example two /21 worth of space surface as one /20); fragmented free space is returned as multiple non-adjacent prefixes (for example a single allocation may surface as /25 + /28). This is why one pool can show a varying number of address prefixes. The module exposes these resolved prefixes as a read-only output, so summarization or fragmentation does not cause Terraform drift.

Ignoring out-of-band subnet changes (ignore_body_changes)

Some Azure controllers modify subnet properties out-of-band - outside Terraform - after the subnet is created. The most common case is Azure Virtual Network Manager (AVNM) routing configurations (or Azure Policy DeployIfNotExists) attaching a managed route table to a subnet. On the next terraform plan the module sees the externally-added routeTable and tries to revert it to the configured value (null), producing perpetual drift and fighting the external controller on every apply.

The module implements the AVM ignore_body_changes interface (TFFR8). It maps to the azapi provider's write-only ignore_body_changes argument: the listed body paths are ignored after create, so the external controller can own them without drift.

There are two ways to set it, and they compose:

  • Per subnet (most common): set ignore_body_changes on an individual entry of the subnets map. This takes precedence over the module-wide value for that subnet.
  • Module-wide / other resources: the root ignore_body_changes object is keyed by resource type (the same snake_case key an AzAPI resource_types map uses). virtual_networks targets the virtual network itself, virtual_networks_subnets applies to every subnet, and virtual_networks_virtual_network_peerings applies to every peering.
module "vnet" {
  source  = "packages/network-virtualnetwork"
  # ... version, name, location, parent_id, address_space ...

  subnets = {
    workload = {
      name             = "snet-workload"
      address_prefixes = ["10.0.1.0/24"]

      # Per-subnet: let AVNM / Azure Policy own the route table association
      # out-of-band. Do NOT also set route_table on this subnet (see note below).
      ignore_body_changes = ["properties.routeTable"]
    }
  }

  # Module-wide equivalents (applied to every subnet / the vnet itself):
  ignore_body_changes = {
    virtual_networks         = ["tags"] # e.g. tags applied by Azure Policy
    virtual_networks_subnets = {
      virtual_networks_subnets = ["properties.routeTable"]
    }
  }
}

Supported paths. Any body property expressed in dot notation, for example properties.routeTable or the top-level tags. The provider ignores whichever paths you list; it does not restrict them to a fixed set, so newer properties work without a module change. Commonly used subnet paths:

Path Property
properties.routeTable Route table association (AVNM routing / Policy DINE) - the canonical case
properties.networkSecurityGroup Network security group association
properties.serviceEndpoints Service endpoints
properties.delegations Subnet delegations

Important - don't manage the same property twice. Several of these properties are also settable through dedicated inputs (route_table, network_security_group, service_endpoints, delegations). When you ignore a path so an external controller can own it, leave the corresponding input unset. Setting the input and ignoring the path means the module renders a value the provider is told to ignore - confusing and self-defeating.

Behaviour and requirements.

  • Paths use dot notation. Individual list items cannot be targeted - ignore the whole list property. Each entry must be a non-empty string; blank entries are rejected with a validation error.
  • ignore_body_changes is a write-only argument (stored in provider-private state). Supplying a non-empty value requires Terraform >= 1.11 and AzAPI >= 2.12. Changes to the list take effect only after an apply.
  • Because empty lists collapse to no argument, the default (nothing ignored) keeps the module usable on Terraform < 1.11 - existing configurations are unaffected.
  • While a path is ignored, configuration changes at that path are not sent to Azure until you remove the path from the list.

ignore_body_changes is not a first-import safeguard. It's write-only, so a value only takes effect starting with the first apply after you set it - it can't protect the very first terraform plan against a resource you just imported.

Importing an existing virtual network

Importing an existing VNet brings its full properties.subnets and properties.virtualNetworkPeerings arrays into state, including entries this module doesn't manage (for example a vWAN hub's service-managed peering). Since this module always manages subnets and peerings as separate child resources (modules/subnet, modules/peering) and never sets either key on the parent body, azapi_resource.vnet (main.tf) carries a static lifecycle.ignore_changes on both paths. Unlike ignore_body_changes, this is native Terraform behavior that applies immediately, so it also covers that first post-import plan.

Prerequisites

For IPAM Features

  • Azure Virtual Network Manager: Required for all IPAM functionality
  • Supported Azure region: IPAM must be available in your target region (see Regional Support)
  • azapi provider: Version ~> 2.12 required for IPAM resource management
  • Proper permissions: Network Manager and IPAM pool management permissions

Migrating from v0.1.x

Version 0.2.0 rewrote the module from azurerm resources to azapi resources and changed the state layout without shipping moved blocks. Current tooling can bridge the resource-type changes: Terraform v1.8.0 added provider-supported moves between resource types, and AzAPI v2.1.0 added moves from azurerm resources to azapi_resource. This module requires Terraform >= 1.9, < 2.0 and AzAPI ~> 2.12. The addresses below were verified against Terraform's move validation and AzAPI's cross-type state conversion using a synthetic v0.1.x state, but the migration has not been applied end to end against a real v0.1.3 deployment. Back up the state first, treat the addresses below as templates, and verify them against terraform state list.

Move retained resources

Write the moved blocks in the root configuration that calls this module, not in the module source. Replace module.vnet with the actual module address and repeat the keyed blocks for every subnet and peering. The current configuration must use the existing Azure resource names: set each subnet name to its old map key and each peering name to the old generated value peering-<key>.

moved {
  from = module.vnet.azurerm_virtual_network.vnet
  to   = module.vnet.azapi_resource.vnet
}

moved {
  from = module.vnet.azurerm_subnet.subnet["subnet_key"]
  to   = module.vnet.module.subnet["subnet_key"].azapi_resource.subnet
}

moved {
  from = module.vnet.azurerm_virtual_network_peering.vnet_peering["peering_key"]
  to   = module.vnet.module.peering["peering_key"].azapi_resource.this[0]
}

The static subnet destination is deliberately unindexed. The subnet submodule already declares moved { from = azapi_resource.subnet, to = azapi_resource.subnet[0] } for the v0.15.0 IPAM change, and Terraform rejects two statements that move into the same instance with an Ambiguous move statements error. Targeting the unindexed address lets Terraform chain the two moves. If the target subnet uses ipam_pools, target module.vnet.module.subnet["subnet_key"].azapi_resource.subnet_ipam[0] instead; that address is indexed because no such chained move exists for it. The peering destination is for the full-virtual-network peering used by v0.1.x and selected by the current default peer_complete_vnets = true.

Remove resources folded into parent bodies

These v0.1.x resources have no destination address because v0.2.0 folded them into the virtual network or subnet body. Configure the equivalent current input first, then use terraform state rm for each address that exists:

State address Equivalent current configuration
module.vnet.azurerm_virtual_network_dns_servers.vnet_dns[0] dns_servers on the virtual network
module.vnet.azurerm_subnet_network_security_group_association.vnet["subnet_key"] subnets["subnet_key"].network_security_group
module.vnet.azurerm_subnet_route_table_association.vnet["subnet_key"] subnets["subnet_key"].route_table
module.vnet.azurerm_subnet_nat_gateway_association.nat_gw["subnet_key"] subnets["subnet_key"].nat_gateway

Do not remove an association from state until the current subnet configuration contains the same NSG, route table, or NAT gateway ID. Otherwise, a later subnet update can remove that association from Azure.

Review the first plan

AzAPI's cross-type state conversion initializes id, name, parent_id, and type, but not body. The first plan after adding the moves therefore shows the configured body being reconciled; this is expected. Review and adjust the configuration until the plan contains only the expected state moves and in-place updates.

Never apply a plan that replaces the virtual network, subnets, or peerings. After applying the reviewed in-place migration, run terraform plan again and iterate until it reports no changes. If a non-replacing plan cannot be established, importing the existing resources into a fresh configuration and state remains the conservative alternative.

Later releases introduced these additional breaking changes:

Version Breaking change
v0.11.0 Removed resource_group_name and subscription_id; supply the resource group resource ID with parent_id.
v0.12.0 Removed the retry options multiplier and randomization_factor, including nested subnet and peering retry objects.
v0.15.0 Removed service_endpoints in favor of service_endpoints_with_location, and required a moved block for existing IPAM subnets. Reversed in v0.20.0: service_endpoints is supported again with names only, while service_endpoints_with_location now raises a validation error.
v0.19.0 Moved locks, role assignments, and diagnostic settings from azurerm to azapi. Locks and diagnostic settings migrate through moved blocks; role assignments are recreated once.

Use GitHub Releases as the authoritative changelog for all versions.

Usage

To use this module in your Terraform configuration, you'll need to provide values for the required variables.

Example - Basic Virtual Network with Subnets

This example shows the most basic usage of the module. It creates a new virtual network with subnets using traditional static addressing.

module "avm-res-network-virtualnetwork" {
  source = "packages/network-virtualnetwork"

  address_space = ["10.0.0.0/16"]
  location      = "eastus2"
  name          = "vnet-demo-eastus2-001"
  parent_id     = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-demo-eastus2-001"
  subnets = {
    "subnet1" = {
      name             = "subnet1"
      address_prefixes = ["10.0.0.0/24"]
    }
    "subnet2" = {
      name             = "subnet2"
      address_prefixes = ["10.0.1.0/24"]
    }
  }
}

Example - IPAM Virtual Network with Multiple Subnets

This example demonstrates IPAM usage with both VNet and subnet address allocation from IPAM pools.

module "avm-res-network-virtualnetwork" {
  source = "packages/network-virtualnetwork"

  location  = "East US"
  name      = "myIPAMVNet"
  parent_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup"

  # VNet address space from IPAM pool
  ipam_pools = [{
    id            = azapi_resource.ipam_pool.id
    prefix_length = 24
  }]

  # Multiple subnets allocated from IPAM pool
  subnets = {
    "web_subnet" = {
      name = "subnet-web"
      ipam_pools = [{
        pool_id       = azapi_resource.ipam_pool.id
        prefix_length = 26
      }]
    }
    "app_subnet" = {
      name = "subnet-app"
      ipam_pools = [{
        pool_id       = azapi_resource.ipam_pool.id
        prefix_length = 26
      }]
    }
    "data_subnet" = {
      name = "subnet-data"
      ipam_pools = [{
        pool_id       = azapi_resource.ipam_pool.id
        prefix_length = 27
      }]
    }
  }
}

Example - Create a subnet on a pre-existing Virtual Network

This example shows how to create a subnet for a pre-existing virtual network using the subnet module.

module "avm-res-network-subnet" {
  source = "Azure/avm-res-network-virtualnetwork/azurerm//modules/subnet"

  parent_id        = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVNet"
  name             = "subnet1"
  address_prefixes = ["10.0.0.0/24"]
}

Troubleshooting

Common IPAM Issues

  • "IPAM subnet creation failed": Ensure parent VNet was created with IPAM pools for its address space
  • "Region not supported": Check the IPAM Regional Support section above
  • "Network Manager not found": Ensure Azure Virtual Network Manager exists before creating IPAM pools
  • "Subnet overlap errors": Module uses retry logic to handle allocation conflicts automatically
  • "Pool exhausted": Check that your IPAM pool has sufficient available address space for the requested subnets
  • CannotHaveDuplicatePoolIds: The same pool is referenced more than once. Use a single ipam_pools entry and increase number_of_ip_addresses instead of adding duplicate entries.
  • only one association of each IP type is allowed: Only one IPv4 pool and one IPv6 pool are permitted per virtual network. Remove the additional same-family pool.
  • CannotMixAddressPrefixAndPoolInPayload: A virtual network cannot combine IPAM pools with a static address_space. Choose one addressing model.
  • SubnetPoolsMustBeSubsetOfVnetPools: A subnet references a pool that its virtual network does not use. Reference the pool on the VNet first.
  • A single pool shows multiple or changing address prefixes: Expected behavior. One allocation is resolved into one or more CIDRs (summarized when contiguous, split when fragmented). These resolved prefixes are read-only and do not cause Terraform drift.

Requirements

The following requirements are needed by this module:

Resources

The following resources are used by this module:

Required Inputs

The following input variables are required:

location

Description: (Optional) The location/region where the virtual network is created. Changing this forces a new resource to be created.

Type: string

parent_id

Description: (Optional) The ID of the resource group where the virtual network will be deployed.

Type: string

Optional Inputs

The following input variables are optional (have default values):

address_space

Description: (Optional) The address spaces applied to the virtual network. You can supply more than one address space.
Either address_space or ipam_pools must be specified, but not both.

Type: set(string)

Default: null

bgp_community

Description: (Optional) The BGP community to send to the virtual network gateway.

Type: string

Default: null

ddos_protection_plan

Description: Specifies an AzureNetwork DDoS Protection Plan.

  • id: The ID of the DDoS Protection Plan. (Required)
  • enable: Enables or disables the DDoS Protection Plan on the Virtual Network. (Required)

Type:

object({
    id     = string
    enable = bool
  })

Default: null

diagnostic_settings

Description: A map of diagnostic settings to create on the Key Vault. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time.

  • name - (Optional) The name of the diagnostic setting. One will be generated if not set, however this will not be unique if you want to create multiple diagnostic setting resources.
  • log_categories - (Optional) A set of log categories to send to the log analytics workspace. Defaults to [].
  • log_groups - (Optional) A set of log groups to send to the log analytics workspace. Defaults to ["allLogs"].
  • metric_categories - (Optional) A set of metric categories to send to the log analytics workspace. Defaults to ["AllMetrics"].
  • log_analytics_destination_type - (Optional) The destination type for the diagnostic setting. Possible values are Dedicated and AzureDiagnostics. Defaults to Dedicated.
  • workspace_resource_id - (Optional) The resource ID of the log analytics workspace to send logs and metrics to.
  • storage_account_resource_id - (Optional) The resource ID of the storage account to send logs and metrics to.
  • event_hub_authorization_rule_resource_id - (Optional) The resource ID of the event hub authorization rule to send logs and metrics to.
  • event_hub_name - (Optional) The name of the event hub. If none is specified, the default event hub will be selected.
  • marketplace_partner_resource_id - (Optional) The full ARM resource ID of the Marketplace resource to which you would like to send Diagnostic LogsLogs.

Type:

map(object({
    name                                     = optional(string, null)
    log_categories                           = optional(set(string), [])
    log_groups                               = optional(set(string), ["allLogs"])
    metric_categories                        = optional(set(string), ["AllMetrics"])
    log_analytics_destination_type           = optional(string, "Dedicated")
    workspace_resource_id                    = optional(string, null)
    storage_account_resource_id              = optional(string, null)
    event_hub_authorization_rule_resource_id = optional(string, null)
    event_hub_name                           = optional(string, null)
    marketplace_partner_resource_id          = optional(string, null)
  }))

Default: {}

dns_servers

Description: (Optional) Specifies a list of IP addresses representing DNS servers.

  • dns_servers: List of IP addresses of DNS servers.

Type:

object({
    dns_servers = list(string)
  })

Default: null

enable_telemetry

Description: This variable controls whether or not telemetry is enabled for the module.
For more information see https://aka.ms/avm/telemetryinfo.
If it is set to false, then no telemetry will be collected.

Type: bool

Default: false

enable_vm_protection

Description: (Optional) Enable VM Protection for the virtual network. Defaults to false.

Type: bool

Default: false

encryption

Description: (Optional) Specifies the encryption settings for the virtual network.

  • enabled: Specifies whether encryption is enabled for the virtual network.
  • enforcement: Specifies the enforcement mode for the virtual network. Possible values are AllowUnencrypted and DropUnencrypted.

Note: When using DropUnencrypted enforcement, the AllowDropUnecryptedVnet subscription feature must be registered first. See the vnet-encryption-setup example for details.

Type:

object({
    enabled     = bool
    enforcement = string
  })

Default: null

extended_location

Description: (Optional) Specifies the extended location of the virtual network.

  • name: The name of the extended location.
  • type: The type of the extended location.

Type:

object({
    name = string
    type = string
  })

Default: null

flow_timeout_in_minutes

Description: (Optional) The flow timeout in minutes for the virtual network. Defaults to 4.

Type: number

Default: null

ignore_body_changes

Description: (Optional) Paths in each resource's body whose changes the azapi provider ignores after creation, letting an out-of-band controller own those properties without producing perpetual terraform plan drift. Prefer Terraform's lifecycle.ignore_changes when the paths are static; use this variable when the paths must be derived from variables or other non-static values.

Keys follow the same naming rule as an AzAPI resource_types map (the snake_case ARM resource type with the Microsoft. prefix dropped), scoped per resource and per submodule:

  • virtual_networks - Ignored body paths for the virtual network managed by this module (for example ["tags"] when Azure Policy applies tags out-of-band).
  • virtual_networks_subnets - Override slot for the subnet submodule. Supply only the keys you want to override.
    • virtual_networks_subnets - Ignored body paths applied to every subnet, for example ["properties.routeTable"] for the AVNM ManagedOnly routing / Azure Policy DINE scenario. A per-subnet ignore_body_changes entry in the subnets map takes precedence over this shared value.
  • virtual_networks_virtual_network_peerings - Override slot for the peering submodule.
    • virtual_networks_virtual_network_peerings - Ignored body paths applied to every peering resource.

Paths use dot notation, for example properties.routeTable or the top-level tags. Individual list items cannot be targeted; ignore the whole list property instead. While a path is ignored, configuration changes at that path are not sent to Azure until the path is removed from the list.

Important: several subnet properties are also settable through dedicated inputs (for example route_table, network_security_group, service_endpoints, delegations). When you ignore a path so an out-of-band controller can own it, leave the corresponding input unset - do not manage the same property from both places.

Supplying a non-empty value requires Terraform 1.11 or later, because ignore_body_changes is a write-only argument held in provider-private state; changes take effect only after an apply. Leaving every list empty (the default) emits no argument, so the module remains usable on earlier Terraform versions.

This variable is not a first-import safeguard. Because it is write-only, a value you set here only takes effect starting with the first apply after you set it - it cannot protect the very first terraform plan you run against a resource you just imported. The virtual network's properties.subnets and properties.virtualNetworkPeerings are instead protected by a static lifecycle.ignore_changes block on azapi_resource.vnet (see main.tf), which applies immediately, including on that first post-import plan, because this module always manages subnets and peerings as separate child resources and never sets either key on the parent body.

Type:

object({
    virtual_networks = optional(list(string), [])
    virtual_networks_subnets = optional(object({
      virtual_networks_subnets = optional(list(string), [])
    }), {})
    virtual_networks_virtual_network_peerings = optional(object({
      virtual_networks_virtual_network_peerings = optional(list(string), [])
    }), {})
  })

Default: {}

ipam_pools

Description: (Optional) Specifies the IPAM settings for requesting an address_space from an IP Pool. Only one IPv4 and one IPv6 pool can be specified.

  • id: The ID of the IPAM pool.
  • number_of_ip_addresses: (Optional) The number of IP addresses to request from the IPAM pool. If not specified, it will be calculated based on the prefix_length.
  • prefix_length: (Optional) The length of the /XX CIDR range to request. for example 24 for a /24. Prefix length must be between 2 and 29 for IPv4 and 48 and 64 for IPv6.

Type:

list(object({
    id                     = string
    number_of_ip_addresses = optional(string)
    prefix_length          = optional(number)
  }))

Default: null

lock

Description: (Optional) Controls the Resource Lock configuration for this resource. The following properties can be specified:

  • kind - (Required) The type of lock. Possible values are \"CanNotDelete\" and \"ReadOnly\".
  • name - (Optional) The name of the lock. If not specified, a name will be generated based on the kind value. Changing this forces the creation of a new resource.

Type:

object({
    kind = string
    name = optional(string, null)
  })

Default: null

name

Description: (Optional) The name of the virtual network to create. If null, existing_virtual_network must be supplied.

Type: string

Default: null

peerings

Description: (Optional) A map of virtual network peering configurations. Each entry specifies a remote virtual network by ID and includes settings for traffic forwarding, gateway transit, and remote gateways usage.

  • name: The name of the virtual network peering configuration.
  • remote_virtual_network_resource_id: The resource ID of the remote virtual network.
  • allow_forwarded_traffic: (Optional) Enables forwarded traffic between the virtual networks. Defaults to false.
  • allow_gateway_transit: (Optional) Enables gateway transit for the virtual networks. Defaults to false.
  • allow_virtual_network_access: (Optional) Enables access from the local virtual network to the remote virtual network. Defaults to true.
  • do_not_verify_remote_gateways: (Optional) Disables the verification of remote gateways for the virtual networks. Defaults to false.
  • enable_only_ipv6_peering: (Optional) Enables only IPv6 peering for the virtual networks. Defaults to false.
  • peer_complete_vnets: (Optional) Enables the peering of complete virtual networks for the virtual networks. Defaults to true.
  • local_peered_address_spaces: (Optional) The address spaces to peer with the remote virtual network. Only used when peer_complete_vnets is set to false.
  • remote_peered_address_spaces: (Optional) The address spaces to peer from the remote virtual network. Only used when peer_complete_vnets is set to false.
  • local_peered_subnets: (Optional) The subnets to peer with the remote virtual network. Only used when peer_complete_vnets is set to false.
  • remote_peered_subnets: (Optional) The subnets to peer from the remote virtual network. Only used when peer_complete_vnets is set to false.
  • use_remote_gateways: (Optional) Enables the use of remote gateways for the virtual networks. Defaults to false.
  • create_reverse_peering: (Optional) Creates the reverse peering to form a complete peering.
  • reverse_name: (Optional) If you have selected create_reverse_peering, then this name will be used for the reverse peer.
  • reverse_allow_forwarded_traffic: (Optional) If you have selected create_reverse_peering, enables forwarded traffic between the virtual networks. Defaults to false.
  • reverse_allow_gateway_transit: (Optional) If you have selected create_reverse_peering, enables gateway transit for the virtual networks. Defaults to false.
  • reverse_allow_virtual_network_access: (Optional) If you have selected create_reverse_peering, enables access from the local virtual network to the remote virtual network. Defaults to true.
  • reverse_do_not_verify_remote_gateways: (Optional) If you have selected create_reverse_peering, disables the verification of remote gateways for the virtual networks. Defaults to false.
  • reverse_enable_only_ipv6_peering: (Optional) If you have selected create_reverse_peering, enables only IPv6 peering for the virtual networks. Defaults to false.
  • reverse_peer_complete_vnets: (Optional) If you have selected create_reverse_peering, enables the peering of complete virtual networks for the virtual networks. Defaults to true.
  • reverse_local_peered_address_spaces: (Optional) If you have selected create_reverse_peering, the address spaces to peer with the remote virtual network. Only used when reverse_peer_complete_vnets is set to false.
  • reverse_remote_peered_address_spaces: (Optional) If you have selected create_reverse_peering, the address spaces to peer from the remote virtual network. Only used when reverse_peer_complete_vnets is set to false.
  • reverse_local_peered_subnets: (Optional) If you have selected create_reverse_peering, the subnets to peer with the remote virtual network. Only used when reverse_peer_complete_vnets is set to false.
  • reverse_remote_peered_subnets: (Optional) If you have selected create_reverse_peering, the subnets to peer from the remote virtual network. Only used when reverse_peer_complete_vnets is set to false.
  • reverse_use_remote_gateways: (Optional) If you have selected create_reverse_peering, enables the use of remote gateways for the virtual networks. Defaults to false.
  • sync_remote_address_space_enabled: (Optional) If the peering sync status changes a plan will be created to sync the peering address space with an azapi update resource. Defaults to false.
  • sync_remote_address_space_triggers: (Optional) A value that when changed will trigger a resync of the remote address space. This must be supplied if sync_remote_address_space_enabled is true. Defaults to null.

timeouts (Optional) supports the following:

  • create - (Defaults to 30 minutes) Used when creating the Virtual Network Peering.
  • delete - (Defaults to 30 minutes) Used when deleting the Virtual Network Peering.
  • read - (Defaults to 5 minutes) Used when retrieving the Virtual Network Peering.
  • update - (Defaults to 30 minutes) Used when updating the Virtual Network Peering.

retry (Optional) supports the following:

  • error_message_regex - (Optional) A list of regular expressions to match against the error message returned by the API. If any of these match, the retry will be triggered.
  • interval_seconds - (Optional) The number of seconds to wait between retries. Defaults to 10.
  • max_interval_seconds - (Optional) The maximum number of seconds to wait between retries. Defaults to 180.

Type:

map(object({
    name                               = string
    remote_virtual_network_resource_id = string
    allow_forwarded_traffic            = optional(bool, false)
    allow_gateway_transit              = optional(bool, false)
    allow_virtual_network_access       = optional(bool, true)
    do_not_verify_remote_gateways      = optional(bool, false)
    enable_only_ipv6_peering           = optional(bool, false)
    peer_complete_vnets                = optional(bool, true)
    local_peered_address_spaces = optional(list(object({
      address_prefix = string
    })))
    remote_peered_address_spaces = optional(list(object({
      address_prefix = string
    })))
    local_peered_subnets = optional(list(object({
      subnet_name = string
    })))
    remote_peered_subnets = optional(list(object({
      subnet_name = string
    })))
    use_remote_gateways                   = optional(bool, false)
    create_reverse_peering                = optional(bool, false)
    reverse_name                          = optional(string)
    reverse_allow_forwarded_traffic       = optional(bool, false)
    reverse_allow_gateway_transit         = optional(bool, false)
    reverse_allow_virtual_network_access  = optional(bool, true)
    reverse_do_not_verify_remote_gateways = optional(bool, false)
    reverse_enable_only_ipv6_peering      = optional(bool, false)
    reverse_peer_complete_vnets           = optional(bool, true)
    reverse_local_peered_address_spaces = optional(list(object({
      address_prefix = string
    })))
    reverse_remote_peered_address_spaces = optional(list(object({
      address_prefix = string
    })))
    reverse_local_peered_subnets = optional(list(object({
      subnet_name = string
    })))
    reverse_remote_peered_subnets = optional(list(object({
      subnet_name = string
    })))
    reverse_use_remote_gateways        = optional(bool, false)
    sync_remote_address_space_enabled  = optional(bool, false)
    sync_remote_address_space_triggers = optional(any, null)
    timeouts = optional(object({
      create = optional(string, "30m")
      read   = optional(string, "5m")
      update = optional(string, "30m")
      delete = optional(string, "30m")
    }), {})
    retry = optional(object({
      error_message_regex  = optional(list(string), ["ReferencedResourceNotProvisioned"])
      interval_seconds     = optional(number, 10)
      max_interval_seconds = optional(number, 180)
    }), {})
  }))

Default: {}

retry

Description: Retry configuration for the resource operations

Type:

object({
    error_message_regex  = optional(list(string), ["ReferencedResourceNotProvisioned"])
    interval_seconds     = optional(number, 10)
    max_interval_seconds = optional(number, 180)
  })

Default: {}

role_assignments

Description: (Optional) A map of role assignments to create on the . The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time.

  • role_definition_id_or_name - The ID or name of the role definition to assign to the principal.
  • principal_id - The ID of the principal to assign the role to.
  • description - (Optional) The description of the role assignment.
  • skip_service_principal_aad_check - (Optional) If set to true, skips the Azure Active Directory check for the service principal in the tenant. Defaults to false.
  • condition - (Optional) The condition which will be used to scope the role assignment.
  • condition_version - (Optional) The version of the condition syntax. Leave as null if you are not using a condition, if you are then valid values are '2.0'.
  • delegated_managed_identity_resource_id - (Optional) The delegated Azure Resource Id which contains a Managed Identity. Changing this forces a new resource to be created. This field is only used in cross-tenant scenario.
  • principal_type - (Optional) The type of the principal_id. Possible values are User, Group and ServicePrincipal. It is necessary to explicitly set this attribute when creating role assignments if the principal creating the assignment is constrained by ABAC rules that filters on the PrincipalType attribute.

Note: only set skip_service_principal_aad_check to true if you are assigning a role to a service principal.

Type:

map(object({
    role_definition_id_or_name             = string
    principal_id                           = string
    description                            = optional(string, null)
    skip_service_principal_aad_check       = optional(bool, false)
    condition                              = optional(string, null)
    condition_version                      = optional(string, null)
    delegated_managed_identity_resource_id = optional(string, null)
    principal_type                         = optional(string, null)
  }))

Default: {}

subnets

Description: (Optional) A map of subnets to create

  • address_prefix - (Optional) The address prefix to use for the subnet. One of address_prefix, address_prefixes, or ipam_pools must be specified.
  • address_prefixes - (Optional) The address prefixes to use for the subnet. One of address_prefix, address_prefixes, or ipam_pools must be specified.
  • ipam_pools - (Optional) IPAM pools to allocate address space from. When specified, the subnet will request address space from these pools. Each pool configuration supports:
    • pool_id: Resource ID of the IPAM pool to allocate from
    • number_of_ip_addresses: (Optional) The number of IP addresses to request from the IPAM pool. If not specified, it will be calculated based on the prefix_length.
    • prefix_length: (Optional) The CIDR prefix length for this subnet (e.g., 24 for /24, 26 for /26)
    • allocation_type: Type of allocation - "Static" (default) or "Dynamic"
  • ignore_body_changes - (Optional) A per-subnet list of body property paths (dot notation, relative to the request body) whose changes the azapi provider should ignore after creation, letting an out-of-band controller own those properties without perpetual drift. This is the per-item override for this subnet and takes precedence over the module-wide ignore_body_changes.virtual_networks_subnets.virtual_networks_subnets value. The canonical use case is AVNM ManagedOnly routing or Azure Policy DINE attaching a route table out-of-band: set ["properties.routeTable"]. Other common paths: properties.networkSecurityGroup, properties.serviceEndpoints, properties.delegations; a top-level tags path is also valid. Uses dot notation and cannot target individual list items (ignore the whole list). Important: these properties are also settable via dedicated inputs (route_table, network_security_group, service_endpoints, delegations) - when you ignore a path so an external controller can own it, leave the matching input unset so the module and the controller don't fight over it. Supplying a non-empty value is a write-only argument (requires Terraform >= 1.11); changes take effect only after an apply. Defaults to [].
  • enforce_private_link_endpoint_network_policies -
  • enforce_private_link_service_network_policies -
  • name - (Required) The name of the subnet. Changing this forces a new resource to be created.
  • default_outbound_access_enabled - (Optional) Whether to allow internet access from the subnet. Defaults to false.
  • private_endpoint_network_policies - (Optional) Enable or Disable network policies for the private endpoint on the subnet. Possible values are Disabled, Enabled, NetworkSecurityGroupEnabled and RouteTableEnabled. Defaults to Enabled. Only applied when private_endpoint_network_policies_enabled is true.
  • private_endpoint_network_policies_enabled - (Optional) Controls whether the privateEndpointNetworkPolicies property is sent to Azure for the subnet. Defaults to true. Set to false to omit the property entirely, which is required in regions that do not support it (e.g. South Africa West) because they reject the property outright. Note: unlike private_link_service_network_policies_enabled (where false sends Disabled), setting this to false removes the property from the request rather than sending a value; to send Disabled, leave this true and set private_endpoint_network_policies = "Disabled".
  • private_link_service_network_policies_enabled - (Optional) Enable or Disable network policies for the private link service on the subnet. Setting this to true will Enable the policy and setting this to false will Disable the policy. Defaults to true.
  • service_endpoint_policies - (Optional) The map of objects with IDs of Service Endpoint Policies to associate with the subnet.
  • service_endpoints - (Optional) A set of service endpoint names to associate with the subnet, for example ["Microsoft.Storage", "Microsoft.Sql"]. Possible values include: Microsoft.AzureActiveDirectory, Microsoft.AzureCosmosDB, Microsoft.ContainerRegistry, Microsoft.EventHub, Microsoft.KeyVault, Microsoft.ServiceBus, Microsoft.Sql, Microsoft.Storage, Microsoft.Storage.Global and Microsoft.Web. Locations are not configurable because Azure implicitly expands service-endpoint locations, which causes perpetual drift.
  • service_endpoints_with_location - Removed. Use service_endpoints instead. This attribute is still declared so that setting it fails with an explanatory error rather than being silently discarded; setting it is always an error.

delegation (This setting is deprecated, use delegations instead) supports the following:

  • name - (Required) A name for this delegation.
  • service_delegation - (Required) The service delegation to associate with the subnet. This is an object with a name property that specifies the name of the service delegation.

delegations supports the following:

  • name - (Required) A name for this delegation.
  • service_delegation - (Required) The service delegation to associate with the subnet. This is an object with a name property that specifies the name of the service delegation.

nat_gateway supports the following:

  • id - (Optional) The ID of the NAT Gateway which should be associated with the Subnet. Changing this forces a new resource to be created.

network_security_group supports the following:

  • id - (Optional) The ID of the Network Security Group which should be associated with the Subnet. Changing this forces a new association to be created.

route_table supports the following:

  • id - (Optional) The ID of the Route Table which should be associated with the Subnet. Changing this forces a new association to be created.

timeouts (Optional) supports the following:

  • create - (Defaults to 30 minutes) Used when creating the Subnet.
  • delete - (Defaults to 30 minutes) Used when deleting the Subnet.
  • read - (Defaults to 5 minutes) Used when retrieving the Subnet.
  • update - (Defaults to 30 minutes) Used when updating the Subnet.

retry (optional) supports the following:

  • error_message_regex - (Optional) A list of regular expressions to match against the error message returned by the API. If any of these match, the retry will be triggered.
  • interval_seconds - (Optional) The number of seconds to wait between retries. Defaults to 10.
  • max_interval_seconds - (Optional) The maximum number of seconds to wait between retries. Defaults to 180.

role_assignments supports the following:

  • role_definition_id_or_name - The ID or name of the role definition to assign to the principal.
  • principal_id - The ID of the principal to assign the role to.
  • description - (Optional) The description of the role assignment.
  • skip_service_principal_aad_check - (Optional) If set to true, skips the Azure Active Directory check for the service principal in the tenant. Defaults to false.
  • condition - (Optional) The condition which will be used to scope the role assignment.
  • condition_version - (Optional) The version of the condition syntax. Leave as null if you are not using a condition, if you are then valid values are '2.0'.
  • delegated_managed_identity_resource_id - (Optional) The delegated Azure Resource Id which contains a Managed Identity. Changing this forces a new resource to be created. This field is only used in cross-tenant scenario.
  • principal_type - (Optional) The type of the principal_id. Possible values are User, Group and ServicePrincipal. It is necessary to explicitly set this attribute when creating role assignments if the principal creating the assignment is constrained by ABAC rules that filters on the PrincipalType attribute.

Type:

map(object({
    address_prefix   = optional(string)
    address_prefixes = optional(list(string))
    name             = string
    ipam_pools = optional(list(object({
      pool_id                = string
      number_of_ip_addresses = optional(string)
      prefix_length          = optional(number)
      allocation_type        = optional(string, "Static")
    })))
    ignore_body_changes = optional(list(string), [])
    nat_gateway = optional(object({
      id = string
    }))
    network_security_group = optional(object({
      id = string
    }))
    private_endpoint_network_policies             = optional(string, "Enabled")
    private_endpoint_network_policies_enabled     = optional(bool, true)
    private_link_service_network_policies_enabled = optional(bool, true)
    route_table = optional(object({
      id = string
    }))
    service_endpoint_policies = optional(map(object({
      id = string
    })))
    service_endpoints               = optional(set(string))
    default_outbound_access_enabled = optional(bool, false)
    sharing_scope                   = optional(string, null)
    # Retained solely so that setting it produces an explanatory error instead
    # of being silently discarded during object type conversion. See the
    # validation block below. Remove in a future release.
    service_endpoints_with_location = optional(list(object({
      service   = string
      locations = optional(list(string), ["*"])
    })))
    delegations = optional(list(object({
      name = string
      service_delegation = object({
        name = string
      })
    })))
    timeouts = optional(object({
      create = optional(string, "30m")
      read   = optional(string, "5m")
      update = optional(string, "30m")
      delete = optional(string, "30m")
    }), {})
    retry = optional(object({
      error_message_regex  = optional(list(string), ["ReferencedResourceNotProvisioned"])
      interval_seconds     = optional(number, 10)
      max_interval_seconds = optional(number, 180)
    }), {})
    role_assignments = optional(map(object({
      role_definition_id_or_name             = string
      principal_id                           = string
      description                            = optional(string, null)
      skip_service_principal_aad_check       = optional(bool, false)
      condition                              = optional(string, null)
      condition_version                      = optional(string, null)
      delegated_managed_identity_resource_id = optional(string, null)
      principal_type                         = optional(string, null)
    })))
  }))

Default: {}

tags

Description: (Optional) Tags of the resource.

Type: map(string)

Default: null

timeouts

Description: Timeouts for the resource operations

Type:

object({
    create = optional(string, "30m")
    read   = optional(string, "5m")
    update = optional(string, "30m")
    delete = optional(string, "30m")
  })

Default: {}

Outputs

The following outputs are exported:

address_spaces

Description: The address spaces of the virtual network.

name

Description: The resource name of the virtual network.

peerings

Description: Information about the peerings created in the module.

Please refer to the peering module documentation for details of the outputs

resource

Description: The Azure Virtual Network resource. This will be null if an existing vnet is supplied.

resource_id

Description: The resource ID of the virtual network.

subnets

Description: Information about the subnets created in the module.

Please refer to the subnet module documentation for details of the outputs

Modules

The following Modules are called:

interfaces

Source: Azure/avm-utl-interfaces/azure

Version: 0.6.0

peering

Source: ./modules/peering

Version:

subnet

Source: ./modules/subnet

Version:

Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.

Release History

Version 0.22.2 - 2026-08-28

What's Changed

Bug Fixes

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.22.1...v0.22.2

Version 0.22.1 - 2026-08-11

What's Changed

🐛 Bug Fixes

Role assignments are no longer replaced on upgrade (#148, closes #137)

When upgrading from a version that migrated role assignments from azurerm to azapi (v0.19.0), the moved-in role assignment's GUID name was not yet known to the upstream random_uuid resource, causing name to resolve to (known after apply). Because name is part of the AzAPI resource identity, this forced a destroy-and-recreate of the role assignment — tearing down the RBAC binding during the apply and risking a transient access outage.

azapi_resource.role_assignments (root and subnet modules) now sets lifecycle { ignore_changes = [name] }. Role assignment names are immutable GUIDs in Azure (never renamed, only replaced), so ignoring name changes is safe and eliminates the forced replacement.

  • No-op for existing consumers — once random_uuid is in state, plans remain idempotent.
  • Only benefits mid-migration upgraders — those moving from a version predating the stable random_uuid name.
  • Validated on real Azure via an upgrade simulation: before the fix, plan = 2 add / 1 destroy (RBAC binding torn down); after, plan = 1 add / 0 destroy, and re-plan reports no changes.

🔧 Maintenance

  • Synced repository with the latest AVM governance templates (relocated agent skills to .github/skills, added .github/agents, regenerated example footers).

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.22.0...v0.22.1

Version 0.22.0 - 2026-08-10

What's Changed

✨ Features

  • CIDR format validation on network inputs (#144, closes #136 & #133)address_space, subnet address_prefix/address_prefixes, and all peering address-space inputs are now validated at plan time with can(cidrhost(...)), across the root module and the subnet/peering submodules. Malformed prefixes (typos, missing mask, non-CIDR strings) now fail fast with a clear, actionable message instead of surfacing as an opaque Azure API error deep in the apply.

🐛 Fixes

  • Out-of-band subnet drift is now detected (#145, closes #62) — both subnet resources set ignore_missing_property = false, so when an external controller (an AVNM ManagedOnly routing configuration, or an Azure Policy DeployIfNotExists assignment) removes a module-managed body property such as properties.routeTable or properties.networkSecurityGroup, Terraform now surfaces the change as drift and offers to restore it rather than silently swallowing it.
    • Validated end-to-end against real Azure AVNM: clean idempotency (the flip introduces zero plan noise) → out-of-band routeTable removal detected as a restore diff → suppression confirmed.
    • When you intend an external controller to own a path, pair this with the existing ignore_body_changes escape hatch (shipped in v0.21.0 / TFFR8) to suppress that single path only — every other managed property keeps its drift protection.

🧪 Test reliability

  • Example region-picker hardening (#145) — stops spurious LocationNotAvailable e2e failures:
    • Direct-picker examples now exclude Azure canary/EUAP regions (eastus2euap, centraluseuap) via region_name_regex.
    • The IPAM examples' hardcoded allowlist drops 7 access-restricted secondary regions (australiacentral, australiacentral2, brazilsoutheast, germanynorth, norwaywest, switzerlandwest, uaecentral), leaving ~40 generally-available regions.

⚠️ Upgrade notes

  • Behavioral change (drift detection): if you have subnets whose routeTable/networkSecurityGroup (or other managed body properties) are currently being changed out-of-band, the next plan after upgrading may show a restore diff that was previously hidden. This is the intended fix. If an external controller is meant to own that property, set ignore_body_changes = ["properties.routeTable"] (per-subnet) — or the module-wide ignore_body_changes.virtual_networks_subnets slot — and leave the corresponding dedicated input unset. See the subnet module README ("Out-of-band changes and drift detection").
  • No provider or Terraform version-floor changes in this release (azapi ~> 2.12, Terraform >= 1.9, unchanged from v0.21.0).

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.21.0...v0.22.0

Version 0.21.0 - 2026-08-10

What's Changed

✨ Features

  • New ignore_body_changes interface (#142, closes #61) — a spec-conformant way to suppress out-of-band drift on VNet, subnet, and peering resources. Implements AVM spec TFFR8.
    • Root-level ignore_body_changes object keyed by resource type (virtual_networks, virtual_networks_subnets, virtual_networks_virtual_network_peerings), plus a per-subnet override that takes precedence.
    • Resolves the AVNM / Azure Policy DINE route-table (and other server-side) infinite-drift problem.
    • Validated in CI and live against real AVNM IPAM pools (apply → idempotency, zero drift → destroy).

📝 Docs

  • Corrected stale peerings variable documentation (#135).

⚠️ Upgrade notes

  • azapi provider minimum is now ~> 2.12ignore_body_changes is a write-only argument introduced in azapi v2.12.0.
  • Terraform required_version floor stays >= 1.9. Per TFFR8, supplying a non-empty ignore_body_changes value requires Terraform ≥ 1.11; the empty default emits null, so consumers on 1.9/1.10 who don't use the feature are unaffected.
  • Note: because the value lives in provider-private state, a change to ignore_body_changes only takes effect after an apply.

🙏 Credits

Thanks to @martinopedal for surfacing the drift issue and the original PR #70.

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.20.0...v0.21.0

Version 0.20.0 - 2026-07-30

[!WARNING] Breaking change: subnet service endpoints. service_endpoints_with_location is removed and now raises a validation error instead of being silently discarded. Configure subnet service endpoints with names only:

subnets = {
  example = {
    name              = "example"
    address_prefixes  = ["10.0.0.0/24"]
    service_endpoints = ["Microsoft.Storage", "Microsoft.KeyVault"]
  }
}

This affects anyone upgrading from v0.15.0 through v0.19.0, where service_endpoints_with_location was the only available input. Azure expands service-endpoint locations implicitly, so the module no longer manages them. This resolves the repeated-diff and silent endpoint-removal behaviour reported in #22, #39, and #50.

Other notable changes

  • The azapi provider floor is now ~> 2.11, which guarantees the upstream fixes for Missing Resource Identity After Read (#56) and the subnet delegation crash (#63).
  • Subnets can omit privateEndpointNetworkPolicies in regions that do not support it (#46).
  • Reverse peering guards gateway-transit create ordering (#57).
  • The README now documents Migrating from v0.1.x using moved blocks, so the v0.2.0 azurerm to azapi rewrite no longer requires destroying and recreating resources (#111).

Thanks to @mr-scripting, @rdeenen1990, @bronius, @smilnovic-adf, and @deepukumark2119 for the reports behind these fixes.

What's Changed

New Contributors

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.19.0...v0.20.0

Version 0.19.0 - 2026-06-17

What's Changed

⚠️ Breaking Changes

  • Interfaces converted from azurerm to azapi (#52) — the resource lock, role assignment, and diagnostic settings interfaces are now implemented with azapi_resource via the Azure/avm-utl-interfaces utility module. The azurerm provider dependency has been removed from the module entirely. (#108)

Input/output compatibility: the lock, role_assignments, and diagnostic_settings variable schemas are unchanged — no inputs or outputs were added, removed, or renamed. Existing configurations do not need to change.

Upgrade impact on terraform apply:

  • Locks & diagnostic settings migrate in place via moved blocks — no recreation.
  • Role assignments are recreated once. Their underlying resource name changes from the azurerm-generated GUID to the utility module's generated name, so Terraform will destroy and re-create each role assignment on the first apply after upgrading. This is a metadata-only churn — the effective access (principal, role, scope) is identical before and after. Plan carefully if you have policies that react to role-assignment lifecycle events.

Why

Aligns the module with the AVM direction of using azapi + shared interface utility modules, reduces provider surface area, and removes the dual-provider (azurerm + azapi) requirement for consumers.

Contributors

  • @kewalaka — original implementation (#52 / #108)
  • @haflidif — maintainer, takeover & CI
  • @jaredfholgate — review

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.18.2...v0.19.0

Version 0.18.2 - 2026-06-17

What's Changed

Bug Fixes

  • Fix extended_location validation (#54) — the validation used contains() with a string as its first argument instead of a list, causing it to error at plan time for any non-null extended_location, making the variable unusable. The check is now a direct equality comparison (var.extended_location.type == "EdgeZone") and is covered by a new unit test. (#107)

Maintenance

  • Repository hygiene (#42) — removed tracked .DS_Store files and ignored them going forward. (#107)
  • Dependencies — consolidated Dependabot bumps for example-only helper modules: Azure/avm-utl-regions/azurerm 0.9.0 → 0.12.0 and Azure/naming/azurerm 0.4.2 → 0.4.3. No impact on the module, its inputs, outputs, or consumers. (#106)

Patch release. The only consumer-facing change is the extended_location validation fix — no inputs or outputs were added, removed, or renamed.

Contributors

  • @haflidif — maintainer
  • @T0biii — repository hygiene (.DS_Store cleanup)
  • @jaredfholgate — review

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.18.1...v0.18.2

Version 0.18.1 - 2026-06-15

What's Changed

Documentation

  • Clarify IPAM allocation rules and pool constraints in the module README (#105). Documents the Azure AVNM platform behavior verified against API 2025-09-01:
    • One IPv4 pool + one IPv6 pool per virtual network (and per subnet) — the RP rejects duplicate or multiple same-family pools (CannotHaveDuplicatePoolIds, only one association of each IP type is allowed).
    • No mixing of IPAM pool allocation and static address_prefixes in the same VNet/subnet (CannotMixAddressPrefixAndPoolInPayload).
    • Subnet pools must be a subset of the parent VNet's pools (SubnetPoolsMustBeSubsetOfVnetPools).
    • Summarization vs. fragmentation of a single number_of_ip_addresses allocation: Azure resolves one allocation entry into one or more CIDRs depending on contiguity of free space — this is read-only and causes no Terraform drift.
  • New "IPAM Allocation Rules and Sizing" section plus expanded IPAM troubleshooting with RP error codes.

Docs-only patch release. No module behavior, inputs, or outputs changed. The validation introduced in v0.18.0 (one IPv4 + one IPv6 pool per VNet) was confirmed correct against the latest Azure API.

Contributors

  • @haflidif — maintainer
  • @jaredfholgate — review

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.18.0...v0.18.1

Version 0.18.0 - 2026-06-15

What's Changed

Features

  • Pass through number_of_ip_addresses for IPAM pools (root module + subnet submodule), enabling single address-count IPAM allocation. Originally contributed by @timja in #67.

Bug Fixes

  • Require number_of_ip_addresses or prefix_length per IPAM pool (XOR validation), preventing a plan-time crash when neither is set. Contributed by @martinopedal in #67.
  • Fix regex for IPAM pool ID validation. Contributed by @walkerk1980 in #65.
  • Stop emitting the unsupported enabled_metric diagnostic block for virtual networks (interface-compliant: the metric_categories input is retained). Contributed by @deni-cpu and @martinopedal in #69.
  • Align IPv6 IPAM pool validation with IPv4 (full /48/64 range, null-guarded). By @haflidif.

Tests

  • Add terraform test unit coverage for ipam_pools variable validations (9 runs). By @haflidif.

Issues fixed

  • Closes #66 — IPAM allocation by address count
  • Closes #64 — regex now allows . in IPAM pool names
  • Closes #43 — removes the unsupported dynamic enabled_metric for virtual networks

Contributors

Huge thanks to everyone whose work is included in this release 🙏

  • @timja — #67
  • @martinopedal — #67, #69
  • @walkerk1980 — #65
  • @deni-cpu — #69
  • @jaredfholgate — review
  • @haflidif — maintainer

Note: External contributions were reimplemented on an owner-controlled release branch (#104) because fork PRs cannot run the AVM CI directly; original authorship is preserved via commit Co-authored-by trailers. Multi-pool IPAM (#102) remains out of scope per the Azure AVNM API constraints discussed in #71 (one IPv4 + one IPv6 pool per VNet, no mixing). #70 is tracked separately.

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.17.1...v0.18.0

Version 0.17.1 - 2026-01-19

What's Changed

New Contributors

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.17.0...v0.17.1

Version 0.17.0 - 2026-01-07

What's Changed

Issues fixed

fixed #48

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.16.0...v0.17.0

Version 0.16.0 - 2025-11-14

What's Changed

New Contributors

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.15.0...v0.16.0

Version 0.15.0 - 2025-10-15

Breaking changes

The deprecated service_endpoints input for subnets has been removed.

We have had to separate the implementation of subnets using IPAM. If you have deployed a subnet with IPAM since that change went out, you'll need to add a moved block to your code into order to migrate the state. E.g.

moved {
  from = module.vnet.module.subnet["subnet01"].azapi_resource.subnet
  to   = module.vnet.module.subnet["subnet01"].azapi_resource.subnet_ipam[0]
}

If you are not using IPAM your state will automatically be migrated.

What's Changed

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.14.1...v0.15.0

Version 0.14.1 - 2025-10-07

What's Changed

Thanks to @Arhughes14 for contributing this change

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.14.0...v0.14.1

Version 0.14.0 - 2025-10-07

🎉 Major New Feature: IPAM Support

This release introduces comprehensive IP Address Management (IPAM) support through Azure Virtual Network Manager, enabling centralized IP governance and automatic conflict prevention.

New Capabilities

  • 🏢 VNet IPAM Allocation - Automatically allocate VNet address space from centralized IPAM pools
  • 🔗 Subnet IPAM Allocation - Dynamic subnet addressing with automatic conflict resolution
  • 🔀 Mixed Addressing - Combine IPAM and traditional subnets within the same VNet
  • 🔄 Enhanced Subnet Module - Standalone subnet module now supports IPAM allocation
  • ⚡ Retry Logic - Robust conflict resolution with 15-second intervals (300s max timeout)

📍 Regional Availability

IPAM is supported in all Azure regions where Virtual Network Manager is available, except: chilecentral, jioindiawest, malaysiawest, qatarcentral, southafricawest, westindia, westus3

🛠 What's New

Core Module

  • Added ipam_pools variable for VNet address space allocation
  • Enhanced subnet configuration with IPAM pool support
  • Integrated retry mechanisms for reliable IPAM operations
  • Maintained full backwards compatibility (zero breaking changes)

Subnet Module

  • Added IPAM allocation capabilities to standalone subnet module
  • Support for dynamic IP assignment from IPAM pools
  • Consistent interface with main module IPAM features

New Examples

  • ipam_basic - Complete IPAM usage with VNet and multiple subnets
  • existing_vnet_ipam_subnets - Adding IPAM subnets to existing IPAM-enabled VNets
  • ipam_vnet_only - IPAM VNet creation with traditional subnet management

🔧 Technical Requirements

  • Azure Virtual Network Manager required for IPAM functionality
  • azapi provider version ~> 2.4
  • Removed time provider dependency (replaced with native azapi retry logic)

📚 Migration Notes

  • No breaking changes - existing configurations work unchanged
  • Optional feature - IPAM can be adopted gradually alongside traditional addressing
  • State compatibility - no state migration required

🐛 Other Improvements

  • Enhanced error handling and retry mechanisms
  • Comprehensive documentation and troubleshooting guides

🙏 Acknowledgments

Special thanks to @ChrisChapman-gh for his initial structure and shell that helped lay the foundation for this IPAM implementation.


What's Changed

New Contributors

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.13.0...v0.14.0

Version 0.13.0 - 2025-10-06

What's Changed

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.12.0...v0.13.0

Version 0.12.0 - 2025-09-29

Breaking Change

This PR removes some of the retry options, but very unlikely they are being used so not expecting much impact.

What's Changed

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.11.0...v0.12.0

Version 0.11.0 - 2025-09-26

Breaking Changes

This release includes a significant breaking change to the module interface.

We have removed the resource_group_name and subscription_id inputs. The resource group ID must now be explicitly provided via the parent_id input.

This change was necessary to align to forthcoming AVM v1 specs as well as fix an underlying idempotency issue with the existing implementation.

We try very hard not to make breaking changes to module interfaces like this and understand the impact it has to consumers of our modules. We do not anticipate any further breaking changes to the interface of this module prior to v1.

What's Changed

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.10.0...v0.11.0

Version 0.10.0 - 2025-08-01

What's Changed

New Contributors

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.9.3...v0.10.0

Version 0.9.3 - 2025-07-24

What's Changed

New Contributors

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/0.9.1...v0.9.3

Version 0.9.2 - 2025-07-03

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/0.9.0...0.9.2

Version 0.9.1 - 2025-07-03

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/0.9.0...0.9.1

Version 0.9.0 - 2025-06-24

Breaking changes

We no longer support azurerm v3 or azapi v1

What's Changed

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.8.1...0.9.0

Version 0.8.1 - 2025-02-06

What's Changed

New Contributors

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.8.0...v0.8.1

Version 0.8.0 - 2025-01-31

What's Changed

Breaking change

  • Update to the version of Terraform CLI support

New Contributors

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.7.2...v0.8.0

Version 0.7.2 - 2025-01-28

What's Changed

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.7.1...v0.7.2

Version 0.7.1 - 2024-11-16

What's Changed

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.7.0...v0.7.1

Version 0.7.0 - 2024-11-15

What's Changed

Releasing as a minor in this dependency change has impact on peering usage.

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.6.0...v0.7.0

Version 0.6.0 - 2024-11-01

What's Changed

This release adds support for v2 of the azapi provider. We have incremented the minor version, but there are no breaking changes and it is backwards compatible with v1 of azapi.

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.5.0...v0.6.0

Version 0.5.0 - 2024-10-29

What's Changed

Added backwards compatible support for v4 of azurerm.

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.4.2...v0.5.0

Version 0.4.2 - 2024-10-11

What's Changed

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.4.1...v0.4.2

Version 0.4.1 - 2024-10-11

What's Changed

New Contributors

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.4.0...v0.4.1

Version 0.4.0 - 2024-07-26

What's Changed

Added the capability to properly peer by subnet and fixed a non-backwards compatible default on peering.

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.3.0...v0.4.0

Version 0.3.0 - 2024-07-17

What's Changed

We added some missing properties and enabled automatic feature enablement for some preview features.

We added the address_prefix singular vartiable to the subnet submodule to support some cases where the address_prefixes variable is not being read by resources that use a subnet.

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.2.4...v0.3.0

Version 0.2.4 - 2024-07-05

What's Changed

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.2.3...v0.2.4

Version 0.2.3 - 2024-05-30

What's Changed

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.2.2...v0.2.3

Version 0.2.2 - 2024-05-29

What's Changed

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.2.1...v0.2.2

Version 0.2.1 - 2024-05-28

What's Changed

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.2.0...v0.2.1

Version 0.2.0 - 2024-05-28

Breaking Changes

v0.2.0 is a re-write of the module, it changes the interface and internal implementation considerably and you will have to update any code and state that is dependent on this module. We try to avoid making updates like this, but in this case we considered the updates valuable enough to make this change. The interface will be stable moving forward.

What's Changed

v0.2.0 moves the module to an AzAPI implementation. The primary driver for this is to support customers that implement common landing zone policies requiring route table and network security groups. You are now able to create a virtual network that meets your policy requirements in one atomic operation avoiding issues with policy blocking deployment.

We have also updated the module to better support common subscription vending scenarios, where application teams manage subnets, but don't managed the virtual network or peering.

We have broken out subnet and peering in sub modules that can be consumed independently. See the documentation and examples for more details on this.

A huge thanks to @kewalaka and @haflidif for all the work on this.

New Contributors

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.1.4...v0.2.0

Version 0.1.4 - 2024-03-20

What's Changed

New Contributors

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.1.3...v0.1.4

Version 0.1.3 - 2023-12-04

What's Changed

New Contributors

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.1.1...v0.1.3

Version 0.1.2 - 2023-10-16

  • changed approach in defining subnets
  • removed ability to create a DDOS plan as this should be a separate module. This module still accepts an existing ddos plan to be integrated to the vnet
  • added capability create a one side peer to another existing vnet

Version 0.1.1 - 2023-10-16

What's Changed

Full Changelog: https://github.com/Azure/terraform-azurerm-avm-res-network-virtualnetwork/compare/v0.1.0...v0.1.1

Version 0.1.0 - 2023-09-29

No release notes were published in the GitHub Release for this version.

 
 {
  "workingFolder": "packages",
  "packages": [
    // packages defined earlier
    {
      "name": "avm-terraform/network-virtualnetwork",
      "version": "0.22.2"
    }
  ]
}

This package has no dependencies

Stats

Selected version:

0.22.2

Downloads this version:

0

Downloads all versions:

48

Latest version:

0.22.2

Latest update:

29-08-2026

avm-terraform

Other versions (42)

0.22.2

0.22.1

0.22.0

0.21.0

0.20.0

0.19.0

0.18.2

0.18.1

0.18.0

0.17.1

Ready to End Infrastructure Code Chaos?

Join infrastructure teams who've moved from scattered repositories to unified package management

Built by infrastructure experts
Who understand your challenges
Complete solutions
No scattered files
See what's deployed where
When it needs updates
Zero vendor lock-in
Packages work without us
No setup fees or contracts Free migration assistance Cancel anytime with no penalties
Direct founder access Zero security incidents in 2+ years Works with any cloud, any CI/CD platform