Skip to content

Azure Networking Module

This OpenTofu module provisions a Virtual Network (vNet) and multiple subnets within a specified Azure Resource Group. It is designed with FinOps in mind, allowing for consistent tagging across resources for cost allocation and management.

Features

  • Dynamic creation of subnets using a map object.
  • Standardized naming conventions.
  • Support for Service Endpoints.
  • FinOps Ready: Integrated tagging for the Virtual Network.

Requirements

No requirements.

Providers

Name Version
azurerm 4.81.0

Modules

No modules.

Resources

Name Type
azurerm_subnet.subnets resource
azurerm_virtual_network.vnet resource

Inputs

Name Description Type Default Required
address_space The address space for the vNet as a CIDR list(string) n/a yes
base_name [d] The base name for the networking resources string n/a yes
location [d] The location of the networks string n/a yes
resource_group_name [d] The name of the resource group for the networks string n/a yes
subnets [d] Definition for the subnets
map(object({
address_prefixes = list(string)
service_endpoints = list(string)

delegation_config = optional(object({
name = string
service_delegation = object({
name = string
actions = list(string)
})
}))
}))
n/a yes
tags A map of tags to apply to the resources. map(string) n/a yes

[d] Destructive: changing this input forces one or more resources to be destroyed and recreated (an OpenTofu/Terraform replacement) rather than updated in place.

Outputs

Name Description
created_subnets Map of subnet details
vnet_id The ID of the virtual network

Example Usage

module "networking" {
  source              = "oci://acrmerkalisdist0c66.azurecr.io/modules/azure/networking?tag=<module-version>"
  base_name           = "app-prod"
  location            = "East US"
  resource_group_name = "rg-prod-networking"
  address_space       = ["10.0.0.0/16"]

  subnets = {
    frontend = {
      address_prefixes  = ["10.0.1.0/24"]
      service_endpoints = ["Microsoft.Storage"]
    },
    backend = {
      address_prefixes  = ["10.0.2.0/24"]
      service_endpoints = ["Microsoft.Sql"]
    }
  }

  tags = {
    Environment = "Production"
    CostCenter  = "IT-101"
    Owner       = "CloudOps"
    Project     = "Skyline"
  }
}

Notes

Azure subnets do not support individual tags; they are typically tracked via the parent Virtual Network or Resource Group.

Available versions

  • v0.9.1