forked from sdcscripts/terraform-az-firewallnva
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azurefirewall.tf
75 lines (60 loc) · 1.82 KB
/
azurefirewall.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
resource "random_id" "randomidfirewall" {
byte_length = 4
}
resource "azurerm_public_ip" "firewall" {
name = "firewall_pip"
location = var.location
resource_group_name = module.hubnetwork.vnet_rg_name
allocation_method = "Static"
sku = "Standard"
domain_name_label = "firewallpip-${random_id.randomidfirewall.hex}"
}
resource "azurerm_firewall" "hub" {
name = "hub_firewall"
location = var.location
resource_group_name = module.hubnetwork.vnet_rg_name
ip_configuration {
name = "ipconfig1"
subnet_id = module.hubnetwork.vnet_subnets[0]
public_ip_address_id = azurerm_public_ip.firewall.id
}
depends_on = [module.hubmanagementvm, module.linuxvmspoke1, module.linuxvmspoke2]
// The firewall seems to slow down the destroy process for all these objects. approx 66% speed up to allow hub to destroy first using this depends on statement
}
resource "azurerm_firewall_network_rule_collection" "rulecollection" {
name = "Allow_ssh_communications_between_spokes"
azure_firewall_name = azurerm_firewall.hub.name
resource_group_name = module.hubnetwork.vnet_rg_name
priority = 100
action = "Allow"
rule {
name = "spoke1-spoke2"
source_addresses = [
module.spoke1network.subnet_prefixes[0]
]
destination_ports = [
"22", "80",
]
destination_addresses = [
module.spoke2network.subnet_prefixes[0]
]
protocols = [
"TCP"
]
}
rule {
name = "spoke2-spoke1"
source_addresses = [
module.spoke2network.subnet_prefixes[0]
]
destination_ports = [
"22", "80",
]
destination_addresses = [
module.spoke1network.subnet_prefixes[0]
]
protocols = [
"TCP"
]
}
}