Azure Virtual Network Terraform module — parameterised, azurerm 4.x, CI-validated.
Enterprise-grade Azure Virtual Network module with comprehensive networking and security features.
✅ Multi-Address Space - Support for multiple CIDR blocks
✅ Advanced Subnets - Delegations, service endpoints, private endpoints
✅ Security Groups - NSGs with granular security rules
✅ Route Tables - Custom routing with BGP integration
✅ DDoS Protection - Azure DDoS Protection Standard
✅ Encryption - VNet encryption support
✅ DNS Configuration - Custom DNS servers
✅ Azure Policy - Compliance and security enforcement
Pin the module to a release tag:
module "virtual_network" {
source = "git::https://github.com/AIRCLOUD-PL/azure-virtual-network-module.git?ref=v1.0.0"
# required inputs
address_space = []
environment = "..."
location = "..."
resource_group_name = "..."
}All inputs and outputs are listed in the generated reference below (Inputs, Outputs). Worked examples live in examples/.
module "virtual_network" {
source = "git::https://github.com/AIRCLOUD-PL/azure-virtual-network-module.git?ref=v1.0.0"
name = "vnet-prod-westeurope-001"
location = "westeurope"
resource_group_name = "rg-production"
environment = "prod"
address_space = ["10.0.0.0/16"]
subnets = {
"default" = {
address_prefixes = ["10.0.1.0/24"]
}
}
tags = {
Environment = "Production"
}
}module "virtual_network" {
source = "git::https://github.com/AIRCLOUD-PL/azure-virtual-network-module.git?ref=v1.0.0"
name = "vnet-prod-westeurope-001"
location = "westeurope"
resource_group_name = "rg-production"
environment = "prod"
address_space = ["10.0.0.0/16", "10.1.0.0/16"]
# DNS Configuration
dns_servers = ["168.63.129.16", "8.8.8.8"]
# DDoS Protection
enable_ddos_protection = true
ddos_protection_plan_id = azurerm_network_ddos_protection_plan.main.id
# Encryption
encryption_enforcement = "AllowUnencrypted"
subnets = {
"web" = {
address_prefixes = ["10.0.1.0/24"]
service_endpoints = ["Microsoft.Storage", "Microsoft.Sql"]
network_security_group_keys = ["web-nsg"]
route_table_keys = ["web-rt"]
}
"app" = {
address_prefixes = ["10.0.2.0/24"]
network_security_group_keys = ["app-nsg"]
route_table_keys = ["app-rt"]
}
"db" = {
address_prefixes = ["10.0.3.0/24"]
network_security_group_keys = ["db-nsg"]
delegations = [
{
name = "sql-delegation"
service_name = "Microsoft.Sql/managedInstances"
actions = [
"Microsoft.Network/virtualNetworks/subnets/join/action",
"Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action",
"Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action"
]
}
]
}
"aks" = {
address_prefixes = ["10.0.4.0/24"]
delegations = [
{
name = "aks-delegation"
service_name = "Microsoft.ContainerService/managedClusters"
actions = [
"Microsoft.Network/virtualNetworks/subnets/join/action"
]
}
]
}
}
network_security_groups = {
"web-nsg" = {
security_rules = [
{
name = "AllowHTTP"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "80"
source_address_prefix = "*"
destination_address_prefix = "*"
},
{
name = "AllowHTTPS"
priority = 110
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "443"
source_address_prefix = "*"
destination_address_prefix = "*"
}
]
}
"app-nsg" = {
security_rules = [
{
name = "AllowFromWeb"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "8080"
source_address_prefix = "10.0.1.0/24"
destination_address_prefix = "*"
}
]
}
"db-nsg" = {
security_rules = [
{
name = "AllowFromApp"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "1433"
source_address_prefix = "10.0.2.0/24"
destination_address_prefix = "*"
}
]
}
}
route_tables = {
"web-rt" = {
routes = [
{
name = "ToInternet"
address_prefix = "0.0.0.0/0"
next_hop_type = "Internet"
}
]
}
"app-rt" = {
disable_bgp_route_propagation = true
routes = [
{
name = "ToFirewall"
address_prefix = "0.0.0.0/0"
next_hop_type = "VirtualAppliance"
next_hop_in_ip_address = "10.0.100.4"
}
]
}
}
tags = {
Environment = "Production"
Security = "High"
Compliance = "SOX"
}
}- Basic - Simple VNet with one subnet
- Complete - Full enterprise networking setup
- Hub-Spoke - Hub and spoke topology
- NSG Rules - Granular inbound/outbound filtering
- Service Endpoints - Secure service access without public IPs
- Private Endpoints - Private connectivity to Azure services
- Route Tables - Custom routing and traffic control
- Azure Policy - Automated compliance enforcement
- DDoS Protection - Advanced DDoS mitigation
- Network Encryption - VNet traffic encryption
- Delegation Support - Service-specific subnet delegation
- Network Watcher - Network monitoring and diagnostics
- Flow Logs - NSG flow logging
- Traffic Analytics - Network traffic insights
Current version: v1.0.0
MIT
| Name | Version |
|---|---|
| terraform | >= 1.5.0 |
| azurerm | ~> 4.0 |
| Name | Version |
|---|---|
| azurerm | 4.81.0 |
No modules.
| Name | Type |
|---|---|
| azurerm_management_lock.vnet_lock | resource |
| azurerm_monitor_diagnostic_setting.vnet_diagnostics | resource |
| azurerm_nat_gateway.nat_gateways | resource |
| azurerm_nat_gateway_public_ip_association.nat_pip_associations | resource |
| azurerm_network_ddos_protection_plan.main | resource |
| azurerm_network_security_group.nsgs | resource |
| azurerm_network_watcher.main | resource |
| azurerm_network_watcher_flow_log.flow_logs | resource |
| azurerm_public_ip.nat_pips | resource |
| azurerm_resource_group.main | resource |
| azurerm_resource_group_policy_assignment.no_rdp_from_internet | resource |
| azurerm_resource_group_policy_assignment.no_ssh_from_internet | resource |
| azurerm_resource_group_policy_assignment.nsg_on_subnets | resource |
| azurerm_route_table.route_tables | resource |
| azurerm_subnet.subnets | resource |
| azurerm_subnet_network_security_group_association.nsg_associations | resource |
| azurerm_subnet_route_table_association.rt_associations | resource |
| azurerm_virtual_network.main | resource |
| azurerm_resource_group.main | data source |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| address_space | Address space for the Virtual Network | list(string) |
n/a | yes |
| create_resource_group | Create resource group if it doesn't exist | bool |
false |
no |
| ddos_protection_plan_id | ID of DDoS Protection Plan | string |
null |
no |
| diagnostic_settings | Diagnostic settings configuration | object({ |
{ |
no |
| dns_servers | List of DNS servers | list(string) |
null |
no |
| enable_ddos_protection | Enable DDoS Protection | bool |
false |
no |
| enable_diagnostic_settings | Enable diagnostic settings for Virtual Network | bool |
true |
no |
| enable_network_watcher | Enable Network Watcher for the region | bool |
false |
no |
| enable_policy_assignments | Enable Azure Policy assignments for this Virtual Network | bool |
true |
no |
| enable_resource_lock | Enable resource lock for Virtual Network | bool |
false |
no |
| encryption_enforcement | Encryption enforcement setting | string |
"Unencrypted" |
no |
| environment | Environment name (e.g., prod, dev, test) | string |
n/a | yes |
| flow_logs_storage_account_id | Storage Account ID for Flow Logs | string |
null |
no |
| location | Azure region where resources will be created | string |
n/a | yes |
| lock_level | Resource lock level: CanNotDelete or ReadOnly | string |
"CanNotDelete" |
no |
| log_analytics_workspace_id | Log Analytics Workspace ID for diagnostics and traffic analytics | string |
null |
no |
| log_analytics_workspace_resource_id | Log Analytics Workspace Resource ID for traffic analytics | string |
null |
no |
| name | Name of the Virtual Network. If null, will be auto-generated. | string |
null |
no |
| naming_prefix | Prefix for Virtual Network naming | string |
"vnet" |
no |
| nat_gateways | Map of NAT Gateways to create | map(object({ |
{} |
no |
| network_security_groups | Map of Network Security Groups to create | map(object({ |
{} |
no |
| resource_group_name | Name of the resource group | string |
n/a | yes |
| route_tables | Map of Route Tables to create | map(object({ |
{} |
no |
| subnets | Map of subnets to create | map(object({ |
{} |
no |
| tags | Tags to apply to all resources | map(string) |
{} |
no |
| Name | Description |
|---|---|
| address_space | Virtual Network address space |
| id | Virtual Network resource ID |
| name | Virtual Network name |
| network_security_group_ids | Map of NSG names to IDs |
| route_table_ids | Map of Route Table names to IDs |
| subnet_address_prefixes | Map of subnet names to address prefixes |
| subnet_ids | Map of subnet names to IDs |
| vnet_guid | Virtual Network GUID |
Browse all modules with usage snippets in the module catalog or on github.com/AIRCLOUD-PL. Built and maintained by AIRCLOUD: DevOps, cloud and AI engineering. Need a hand with Azure landing zones or platform engineering? See aircloud.com.pl/consulting.
