Contributor role on a resource group
Create storage account for remote state backend
Build a reusable Terraform module for an Azure Virtual Network. Learn module structure: input variables, resources, and outputs.
1 variable "resource_group_name" { 2 type = string 3 description = "Name of the resource group to deploy network resources into" 4 } 5 6 variable "location" { 7 type = string 8 description = "Azure region for all network resources" 9 } 10 11 variable "vnet_name" { 12 type = string 13 description = "Name for the virtual network" 14 } 15 16 variable "address_space" { 17 type = list(string) 18 description = "Address space CIDRs for the VNet" 19 default = ["10.0.0.0/16"] 20 21 validation { 22 condition = length(var.address_space) > 0 23 error_message = "At least one address space CIDR must be provided." 24 } 25 } 26 27 variable "subnets" { 28 type = map(object({ 29 address_prefix = string 30 })) 31 description = "Map of subnet name → address_prefix" 32 default = { 33 "default" = { address_prefix = "10.0.1.0/24" } 34 } 35 } 36 37 variable "tags" { 38 type = map(string) 39 description = "Resource tags" 40 default = {} 41 }
modules/network/ with 3 files; terraform validate passes
Sign in to share your feedback and join the discussion.