I am trying to figure out a way to manage Azure Firewall policy at scale. The resource I am using is a collection group. Does anyone know of a way I could breakout the application and network rule sections to different files (each application would have its own file in the repo).
PS. I am not a developer, still a dumb network guy playing around in a software world.
resource "azurerm_firewall_policy_rule_collection_group" "example" {
name = "example-fwpolicy-rcg"
firewall_policy_id = azurerm_firewall_policy.example.id
priority = 500
application_rule_collection {
name = "app_rule_collection1"
priority = 500
action = "Deny"
rule {
name = "app_rule_collection1_rule1"
protocols {
type = "Http"
port = 80
}
protocols {
type = "Https"
port = 443
}
source_addresses = ["10.0.0.1"]
destination_fqdns = ["*.microsoft.com"]
}
}
network_rule_collection {
name = "network_rule_collection1"
priority = 400
action = "Deny"
rule {
name = "network_rule_collection1_rule1"
protocols = ["TCP", "UDP"]
source_addresses = ["10.0.0.1"]
destination_addresses = ["192.168.1.1", "192.168.1.2"]
destination_ports = ["80", "1000-2000"]
}
}
I have no idea where to even start to fix this issue, it is a bit above my skills.
2
Answers
I have created Azure Firewall Policy with Dynamic Block using Terraform.
Firewall.tf
variable.tf
Pass the Network rule values in below format.
Terraform Apply:
Reference: Module with nested dynamic blocks by
CavernousNylon
I still don’t think this will work, here there would be the need for multiple rules within the same network_rule_collection. You have a firewall collection group, within that group you can have multiple network_rule_collections, within the network_rule_collections you have multiple rules. So for example
1 firewall rule group
2 network rule collections (A & B)
5 rules in network collection A, 2 rules in network collection B