Lesson 2 of 4 · Azure with Terraform
VNets and subnets
An Azure virtual network provides a private address space, and subnets divide it for workloads. As with other clouds, routing and network security rules determine real access behaviour.
Example
resource "azurerm_virtual_network" "main" {
name = "vnet-training"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
}Step by step
- Create the resource group first.
- Choose a non-overlapping address space.
- Create subnets for workload boundaries.
- Apply network security rules deliberately.
Common mistakes to avoid
- Using a subnet range outside the VNet address space.
- Assuming every subnet should allow public ingress.