Skip to content

Opinionated Terraform module that manages Azure Virtual Networks and related components

Notifications You must be signed in to change notification settings

nkyorov/terraform-azurerm-networking

Repository files navigation

AzureRM Networking Module

This module allows managing resources related to Azure networks:

  • Virtual Networks
  • Subnets
  • Network security groups
  • Network security group rules

Examples

tfvars

You can set up the variables in terraform.tfvars file

location            = "westeurope"
resource_group_name = ""
tags                = {}
virtual_network = {
  name          = ""
  address_space = [""]
  subnets = {
    "" = {
      address_prefixes = [""]
      network_security_group = {
        name = ""
        rules = [
          {
            name                       = ""
            priority                   = 100
            direction                  = "Inbound"
            access                     = "Allow"
            protocol                   = "Tcp"
            source_port_range          = "*"
            destination_port_range     = "80"
            source_address_prefix      = "*"
            destination_address_prefix = "*"
          }
        ]
      }
    }
  }
}

Multiple Security Rules

You can configure multiple NSG rules for one or multiple

module "naming" {
  source  = "Azure/naming/azurerm"
  version = "0.4.1"

  suffix = ["multiple-security-rules"]
}

#tflint-ignore: all
module "network" {
  source = "../../"

  resource_group_name = module.naming.resource_group.name
  virtual_network = {
    name          = module.naming.virtual_network.name
    address_space = ["10.0.0.0/16"]
    subnets = {
      "my-subnet-1" = {
        address_prefixes = ["10.0.1.0/24"]
        network_security_group = {
          name = "nsg1"
          rules = [
            {
              name                       = "rule1"
              priority                   = 100
              direction                  = "Inbound"
              access                     = "Allow"
              protocol                   = "Tcp"
              source_port_range          = "*"
              destination_port_range     = "80"
              source_address_prefix      = "*"
              destination_address_prefix = "*"
            },
            {
              name                       = "rule2"
              priority                   = 200
              direction                  = "Inbound"
              access                     = "Allow"
              protocol                   = "Tcp"
              source_port_range          = "*"
              destination_port_range     = "443"
              source_address_prefix      = "*"
              destination_address_prefix = "*"
            }
          ]
        }
      }
    }
  }
  tags = {}
}

Inputs

Name Description Type Default Required
location The location/region where the virtual network is created. string "westeurope" no
resource_group_name The name of the resource group in which to create the virtual network. string n/a yes
tags A mapping of tags to assign to the resource. map(string) {} no
virtual_network Represents a virtual network.
object({
name = string
address_space = list(string)
subnets = map(object({
address_prefixes = list(string)
network_security_group = optional(object({
name = optional(string)
rules = optional(list(object({
name = string
priority = number
direction = string
access = string
protocol = string
source_port_range = string
destination_port_range = string
source_address_prefix = string
destination_address_prefix = string
})), [])
}), {})
}))
})
n/a yes

Outputs

Name Description
vnet_id The virtual network ID.
vnet_name The name of the virtual network.

About

Opinionated Terraform module that manages Azure Virtual Networks and related components

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages