Files

Azure Networking Module

Purpose: Create Azure Virtual Network with subnets and network security groups Status: Complete


Usage

module "networking" {
  source = "../../modules/azure/networking"

  resource_group_name = "rg-example"
  location           = "eastus"
  vnet_name          = "vnet-example"
  address_space      = ["10.0.0.0/16"]

  subnets = {
    frontend = {
      name             = "snet-frontend"
      address_prefixes = ["10.0.1.0/24"]
      service_endpoints = ["Microsoft.Storage"]
    }
    backend = {
      name             = "snet-backend"
      address_prefixes = ["10.0.2.0/24"]
      service_endpoints = []
    }
  }

  network_security_groups = {
    frontend_nsg = {
      name       = "nsg-frontend"
      subnet_key = "frontend"
      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 = "*"
        }
      ]
    }
  }

  tags = {
    Environment = "production"
  }
}

Inputs

Name Description Type Default Required
resource_group_name Name of the resource group string - yes
location Azure region string - yes
vnet_name Name of the virtual network string - yes
address_space Address space for the virtual network list(string) - yes
subnets Map of subnets to create map(object) {} no
network_security_groups Map of network security groups map(object) {} no
tags Tags to apply map(string) {} no

Outputs

Name Description
vnet_id Virtual network ID
vnet_name Virtual network name
subnet_ids Map of subnet names to IDs
subnet_names Map of subnet names
nsg_ids Map of NSG names to IDs

Status: Complete - Ready for use