-
Notifications
You must be signed in to change notification settings - Fork 0
/
nacl.tf
96 lines (84 loc) · 3.29 KB
/
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
resource "aws_network_acl" "db_secure_zone" {
vpc_id = aws_vpc.project_vpc.id
subnet_ids = aws_subnet.private_db_subnets[*].id
}
resource "aws_network_acl" "app_secure_zone" {
vpc_id = aws_vpc.project_vpc.id
subnet_ids = aws_subnet.private_app_subnets[*].id
}
resource "aws_network_acl" "alb_zone" {
vpc_id = aws_vpc.project_vpc.id
subnet_ids = aws_subnet.public_subnets[*].id
}
# Ingress Rules for DB NACL (applies to DB subnets)
resource "aws_network_acl_rule" "db-ingress-secure-zone-rules" {
for_each = { for rule in local.db_nacl_ingress_rules : rule.priority => rule }
network_acl_id = aws_network_acl.db_secure_zone.id
rule_number = each.value.priority
egress = false
protocol = each.value.protocol
rule_action = "allow"
cidr_block = each.value.cidr_block
from_port = each.value.from_port
to_port = each.value.to_port
}
# Egress Rules for DB NACL (applies to DB subnets)
resource "aws_network_acl_rule" "db-egress-secure-zone-rules" {
for_each = { for rule in local.db_nacl_egress_rules : rule.priority => rule }
network_acl_id = aws_network_acl.db_secure_zone.id
rule_number = each.value.priority
egress = true
protocol = each.value.protocol
rule_action = "allow"
cidr_block = each.value.cidr_block
from_port = each.value.from_port
to_port = each.value.to_port
}
# Ingress Rules for APP NACL (applies to APP subnets)
resource "aws_network_acl_rule" "app-ingress-secure-zone-rules" {
for_each = { for rule in local.app_nacl_ingress_rules : rule.priority => rule }
network_acl_id = aws_network_acl.app_secure_zone.id
rule_number = each.value.priority
egress = false
protocol = each.value.protocol
rule_action = "allow"
cidr_block = each.value.cidr_block
from_port = each.value.from_port
to_port = each.value.to_port
}
# Egress Rules for APP NACL (applies to APP subnets)
resource "aws_network_acl_rule" "app-egress-secure-zone-rules" {
for_each = { for rule in local.app_nacl_egress_rules : rule.priority => rule }
network_acl_id = aws_network_acl.app_secure_zone.id
rule_number = each.value.priority
egress = true
protocol = each.value.protocol
rule_action = "allow"
cidr_block = each.value.cidr_block
from_port = each.value.from_port
to_port = each.value.to_port
}
# Ingress Rules for ALB NACL
resource "aws_network_acl_rule" "alb-ingress-secure-zone-rules" {
for_each = { for rule in local.alb_nacl_ingress_rules : rule.priority => rule }
network_acl_id = aws_network_acl.alb_zone.id
rule_number = each.value.priority
egress = false
protocol = each.value.protocol
rule_action = "allow"
cidr_block = each.value.cidr_block
from_port = each.value.from_port
to_port = each.value.to_port
}
# Egress Rules for ALB NACL
resource "aws_network_acl_rule" "alb-egress-secure-zone-rules" {
for_each = { for rule in local.alb_nacl_egress_rules : rule.priority => rule }
network_acl_id = aws_network_acl.alb_zone.id
rule_number = each.value.priority
egress = true
protocol = each.value.protocol
rule_action = "allow"
cidr_block = each.value.cidr_block
from_port = each.value.from_port
to_port = each.value.to_port
}