Skip to content

Commit

Permalink
fix: Removes Network Security Groups for subnets without rules
Browse files Browse the repository at this point in the history
  • Loading branch information
dploeger committed Mar 16, 2023
1 parent 5f85cac commit c32d01a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions firewall.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
resource "azurerm_subnet_network_security_group_association" "nsgassociation-subnet" {
for_each = var.subnets
for_each = {for subnet, value in var.subnets: subnet => value if length(value.rules) > 0}

subnet_id = azurerm_subnet.subnet[each.key].id
network_security_group_id = azurerm_network_security_group.network-security-group-subnet[each.key].id
}

resource "azurerm_network_security_group" "network-security-group-subnet" {
for_each = var.subnets
for_each = {for subnet, value in var.subnets: subnet => value if length(value.rules) > 0}

location = var.location
name = "${lower(var.project)}${lower(var.stage)}netsg${each.key}"
Expand Down

0 comments on commit c32d01a

Please sign in to comment.