Skip to content

Instantly share code, notes, and snippets.

@jlucktay
Created January 8, 2019 14:44
Show Gist options
  • Save jlucktay/6b8c3c454d43cf4565779118e9bf5bbb to your computer and use it in GitHub Desktop.
Save jlucktay/6b8c3c454d43cf4565779118e9bf5bbb to your computer and use it in GitHub Desktop.
Network rule collection deleted when updating tags on firewall hashicorp/terraform-provider-azurerm#2621
variable "tags" {
description = "A map of tag values for all Azure resources capable of being tagged."
type = "map"
}
locals {
location = "UK South"
name = "AzureRMProvider-FirewallIssue"
}
resource "azurerm_firewall" "main" {
name = "${local.name}"
location = "${azurerm_resource_group.main.location}"
resource_group_name = "${azurerm_resource_group.main.name}"
tags = "${var.tags}"
ip_configuration {
internal_public_ip_address_id = "${azurerm_public_ip.main.id}"
name = "${azurerm_public_ip.main.name}"
subnet_id = "${azurerm_subnet.main.id}"
}
}
resource "azurerm_firewall_network_rule_collection" "AllowAllOutbound" {
name = "${azurerm_firewall.main.name}-AllowAllOutbound"
azure_firewall_name = "${azurerm_firewall.main.name}"
resource_group_name = "${azurerm_resource_group.main.name}"
action = "Allow"
priority = 999
rule {
name = "AllowAllOutbound"
destination_addresses = [
"0.0.0.0/0",
]
source_addresses = [
"10.0.0.0/8",
"172.16.0.0/12",
"192.168.0.0/16",
]
destination_ports = ["*"]
protocols = ["Any"]
}
}
resource "azurerm_public_ip" "main" {
name = "${local.name}"
ip_version = "IPv4"
location = "${azurerm_resource_group.main.location}"
public_ip_address_allocation = "Static"
resource_group_name = "${azurerm_resource_group.main.name}"
sku = "Standard"
tags = "${var.tags}"
}
resource "azurerm_resource_group" "main" {
name = "${local.name}"
location = "${local.location}"
tags = "${var.tags}"
}
resource "azurerm_subnet" "main" {
name = "AzureFirewallSubnet"
address_prefix = "10.0.0.0/16"
resource_group_name = "${azurerm_resource_group.main.name}"
virtual_network_name = "${azurerm_virtual_network.main.name}"
}
resource "azurerm_virtual_network" "main" {
name = "${local.name}"
location = "${local.location}"
resource_group_name = "${azurerm_resource_group.main.name}"
tags = "${var.tags}"
address_space = ["10.0.0.0/8"]
}
tags = {
foo = "bar"
baz = "qux"
quux = "corge"
uier = "grault"
garply = "waldo"
fred = "plugh"
thud = "mos"
henk = "def"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment