-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsecure-nacl.tf
63 lines (56 loc) · 2.1 KB
/
secure-nacl.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
resource "aws_network_acl_rule" "secure_in_requester_from_accepter" {
for_each = {
for inbound_port in local.secure_inbound_ports : "${inbound_port.cidr}:${inbound_port.port}" => inbound_port
if try(var.attachment, false) == true
}
network_acl_id = var.secure_network_acl_id
rule_number = 1000 + index(local.secure_inbound_ports, each.value)
egress = false
protocol = each.value.protocol
rule_action = "allow"
cidr_block = each.value.cidr
from_port = each.value.port
to_port = each.value.port == 0 ? "65535" : each.value.port
}
resource "aws_network_acl_rule" "secure_out_requester_to_accepter" {
for_each = {
for outbound_port in local.secure_outbound_ports : "${outbound_port.cidr}:${outbound_port.port}" => outbound_port
if try(var.attachment, false) == true
}
network_acl_id = var.secure_network_acl_id
rule_number = 1000 + index(local.secure_outbound_ports, each.value)
egress = true
protocol = each.value.protocol
rule_action = "allow"
cidr_block = each.value.cidr
from_port = each.value.port
to_port = each.value.port == 0 ? "65535" : each.value.port
}
resource "aws_network_acl_rule" "secure_in_requester_ephemeral" {
for_each = {
for network in var.secure_route : network.cidr => network
if try(network.nacl_inbound_ephemeral_ports, false) == true
}
network_acl_id = var.secure_network_acl_id
rule_number = 2000 + index(var.secure_route, each.value)
egress = false
protocol = "tcp"
rule_action = "allow"
cidr_block = each.value.cidr
from_port = 1024
to_port = 65535
}
resource "aws_network_acl_rule" "secure_out_requester_ephemeral" {
for_each = {
for network in var.secure_route : network.cidr => network
if try(network.nacl_outbound_ephemeral_ports, false) == true
}
network_acl_id = var.secure_network_acl_id
rule_number = 2000 + index(var.secure_route, each.value)
egress = true
protocol = "tcp"
rule_action = "allow"
cidr_block = each.value.cidr
from_port = 1024
to_port = 65535
}