aztfm / terraform-azurerm-virtual-network

Terraform module for Microsoft Azure to manage Virtual Network resource.
https://registry.terraform.io/modules/aztfm/virtual-network/azurerm/
MIT License
7 stars 13 forks source link

Associate a network security group with a subnet #3

Open gareda opened 3 years ago

gareda commented 3 years ago

Description

Add an optional parameter to subnets that allows the ability to associate a subnet with a network security group.

New or affected parameter(s)/configuration(s)

subnets.network_security_grouo_id

Potential Terraform Configuration

resource "azurerm_resource_group" "rg" {
  name     = "terraform-azurerm-virtual-network"
  location = "West Europe"
}

resource "azurerm_nat_gateway" "nat" {
  name                = "nat-gateway"
  location            = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
}

module "virtual-network" {
  source              = "aztfm/virtual-network/azurerm"
  version             = ">=1.0.0"
  name                = "virtual-network"
  resource_group_name = azurerm_resource_group.rg.name
  location            = azurerm_resource_group.rg.location
  address_space       = ["10.0.0.0/16"]
  subnets = [
    {
      name                      = "subnet1"
      address_prefix            = "10.0.0.0/24"
      network_security_grouo_id = azurerm_network_security_group.nsg.id
    }
  ]
}

References

gareda commented 5 months ago