A comprehensive Terraform lab environment that demonstrates Azure Virtual Network Manager (AVNM) with advanced IP Address Management (IPAM) capabilities. This lab showcases modern cloud networking patterns including hub-spoke topology, dynamic subnet allocation, and centralized network management.
This lab deploys a simplified 2-module architecture that creates a complete hub-spoke network topology with automatic IP address management:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Spoke VNet 1 β β Hub VNet β β Spoke VNet 2 β
β (Dynamic IPs) βββββΊβ Azure Firewall βββββΊβ (Dynamic IPs) β
β β β 10.1.0.0/16 β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βββββββββββββββββββ
β Spoke VNet 3 β
β (Dynamic IPs) β
βββββββββββββββββββ
- β Hub-Spoke Topology with Azure Virtual Network Manager
- β
Dynamic IP Allocation from centralized IPAM pool (
10.0.0.0/14) - β Automatic Subnet Management - no manual IP planning required
- β Azure Firewall with routing and security rules
- β Network Security Groups and route tables
- β Conflict Prevention through AVNM IPAM
- β Scalable Design - easily add more spokes
- β Infrastructure as Code with Terraform
| Module | Purpose | Resources |
|---|---|---|
1-hub-spoke-lz |
Complete networking foundation | β’ Resource Group β’ Hub & Spoke VNets β’ Azure Virtual Network Manager β’ IPAM Pool (10.1.0.0/14) β’ Dynamic Subnet Allocation β’ Azure Firewall β’ Network Security Groups β’ Route Tables β’ Network Connectivity Configuration |
2-compute |
Virtual machines and compute | β’ Virtual Machines β’ Network Interfaces β’ Public IPs β’ Compute-related resources |
- GitHub account
- Azure subscription with Contributor access
- Basic understanding of Azure networking concepts
Navigate to this repository and create a new Codespace:
# Click "Code" β "Codespaces" β "Create codespace on main"Login to your Azure account:
az login
# If you have issues, try:
az login --use-device-codeUpdate the answers.json file with your Azure details:
{
"subscriptionId": "your-subscription-id-here",
"location": "eastus2",
"resourceGroupName": "rg-avnm-lab"
}
β οΈ Important: After updating theanswers.jsonfile, make sure to save the file by pressingCtrl+S(Windows/Linux) orCmd+S(Mac) before proceeding to the next step. The deployment scripts rely on the saved values in this file.
Run the automated deployment script:
./deploy.ps1Deployment Process:
- Module 1: Deploys complete networking + AVNM + IPAM (5-10 minutes)
- Module 2: Deploys virtual machines and compute resources (3-5 minutes)
Check the allocated IP address ranges:
cd Modules/1-hub-spoke-lz
terraform output spoke_subnet_allocated_prefixesThe lab uses Azure Virtual Network Manager's IPAM capabilities for complete dynamic allocation:
- Pool Range:
10.0.0.0/14(262,144 total IP addresses) - Hub VNet Allocation: 65,536 IPs (effectively
/16VNet) - Spoke VNet Allocation: 256 IPs per spoke VNet (effectively
/24VNets) - Firewall Subnet Allocation: 256 IPs (effectively
/24subnet) - Spoke Subnet Allocation: 32 IPs per spoke subnet (effectively
/27subnets) - Automatic Assignment: No manual IP planning required
- Conflict Prevention: AVNM ensures no overlapping ranges
- Hub VNet: Dynamically allocated from IPAM pool (gets
/16range)- Azure Firewall Subnet: Dynamically allocated (gets
/24range)
- Azure Firewall Subnet: Dynamically allocated (gets
- Spoke VNets: Dynamically allocated from IPAM pool
- Spoke 1: Automatically assigned
/24VNet - Spoke 2: Automatically assigned
/24VNet - Spoke 3: Automatically assigned
/24VNet
- Spoke 1: Automatically assigned
- Spoke Subnets: Dynamically allocated within their VNets
- Each subnet gets automatically assigned
/27subnet
- Each subnet gets automatically assigned
- Network Security Groups: Applied to all spoke subnets
- Route Tables: Force all traffic through Azure Firewall
- Firewall Rules: Allow inter-spoke communication and internet access
# View hub VNet allocation
terraform output hub_vnet_allocated_prefixes
# View spoke VNet allocations
terraform output spoke_vnet_allocated_prefixes
# View firewall subnet allocation
terraform output firewall_subnet_allocated_prefixes
# View spoke subnet allocations
terraform output spoke_subnet_allocated_prefixesterraform output network_manager_id
terraform output connectivity_configuration_id- Navigate to Network Manager in Azure Portal
- Check IP Address Management β IP Address Pools
- View Configurations β Connectivity configurations
- Monitor Deployments status
When finished with the lab, run the destroy script:
./destroy.ps1Destruction Order:
- Compute resources (VMs, NICs)
- Networking infrastructure (VNets, AVNM, Firewall)
- Username:
azureadmin - Password:
AzureAdmin123!
- Access spoke VMs through the hub network
- All traffic is routed through Azure Firewall
To add additional spoke networks, update the terraform.tfvars file:
vnet_name_spokes = [
"vnet-avnm-spoke1",
"vnet-avnm-spoke2",
"vnet-avnm-spoke3",
"vnet-avnm-spoke4" # Add new spoke
]The IPAM pool will automatically allocate VNet and subnet ranges for new spokes.
Modify IP allocation in terraform.tfvars:
hub_vnet_ip_count = "131072" # Allocates /15 hub VNet instead of /16
vnet_ip_count = "512" # Allocates /23 spoke VNets instead of /24
firewall_subnet_ip_count = "512" # Allocates /23 firewall subnet instead of /24
subnet_ip_count = "64" # Allocates /26 spoke subnets instead of /27After completing this lab, you will understand:
- β Azure Virtual Network Manager concepts and capabilities
- β IP Address Management (IPAM) and dynamic allocation
- β Hub-spoke network topology design patterns
- β Azure Firewall configuration and routing
- β Network Security Groups and traffic control
- β Infrastructure as Code best practices with Terraform
- β Automated deployment and destruction workflows
- Region Support: Ensure AVNM is available in your chosen region (recommended:
eastus2) - Permissions: Requires Contributor access to create Network Manager resources
- VM SKUs: Default VM size is suitable for most regions, modify if needed
- Cost Management: Remember to destroy resources when not in use
Feel free to submit issues, fork the repository, and create pull requests for improvements.
This project is licensed under the MIT License - see the LICENSE file for details.
Happy Networking! π
This lab demonstrates modern Azure networking capabilities with Infrastructure as Code best practices.