How azure-terraform/terraform-azurerm-virtual-network works
Project type and purpose
• This is a Terraform module (“Azure – Virtual Network Module”) designed to provision Azure infrastructure: a Virtual Network (VNet), its subnets, route tables, network security groups (NSGs), and peerings.
• It is not an application codebase, but an Infrastructure-as-Code (IaC) project that defines reusable infrastructure components.
File structure
• Top-level files:
• main.tf, variables.tf, output.tf, locals.tf – the root module that instantiates resources (azurerm_virtual_network, azurerm_route_table, azurerm_subnet, peerings, etc.)
• versions.tf – provider and Terraform version constraints
• examples/ – three example scenarios (aks, bastion, custom_routes) each with its own main.tf to demonstrate module usage
• .github/workflows – CI for doc generation, linting, or validation
• subnet/ – a child module (re-used for both AKS subnets and generic subnets) with its own main.tf, locals.tf, output.tf, variables.tf
• Key patterns:
• Modular structure (root vs subnet child module)
• Examples to illustrate different subnet configurations
• Use of maps/objects to drive variable-driven provisioning
README for additional insights
• It lists inputs (address_space, subnets, route_tables, peers, naming rules, tags) and outputs (vnet, subnets, NSG IDs/names, route_tables).
• It references the AzureRM provider, Terraform ≥0.13.0, and links to Azure resource docs.
• It documents the two modules (root and ./subnet) and the resources created (virtual_network, subnet, route_table, route, peering, subnet_route_table_association).
Elements
• Clear labels for: Terraform CLI, Root Module, Subnet Module, AzureRM Provider, Azure ARM components
• From CLI → Root Module
• Root Module → Subnet Module
• Modules → AzureRM provider
• Provider → Azure ARM
• Another for provider plugin
• A third for actual Azure resources
• Modules in containers to visually distinguish root vs child modules
• Number of instances (e.g., “n subnets created via subnet module”)