forked from DNXLabs/terraform-aws-network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnacl-secure.tf
81 lines (72 loc) · 2.49 KB
/
nacl-secure.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
resource "aws_network_acl" "secure" {
vpc_id = "${aws_vpc.default.id}"
subnet_ids = ["${aws_subnet.secure.*.id}"]
tags = "${merge(
var.tags,
map(
"Name", "${var.name}-ACL-Secure",
"Scheme", "secure",
"EnvName", "${var.name}"
)
)}"
}
###########
# EGRESS
###########
resource "aws_network_acl_rule" "out_secure_to_secure" {
count = "${length(aws_subnet.secure.*.cidr_block)}"
network_acl_id = "${aws_network_acl.secure.id}"
rule_number = "${count.index + 1}"
egress = true
protocol = -1
rule_action = "allow"
cidr_block = "${aws_subnet.secure.*.cidr_block[count.index]}"
}
resource "aws_network_acl_rule" "out_secure_to_private" {
count = "${length(aws_subnet.private.*.cidr_block)}"
network_acl_id = "${aws_network_acl.secure.id}"
rule_number = "${count.index + 101}"
egress = true
protocol = -1
rule_action = "allow"
cidr_block = "${aws_subnet.private.*.cidr_block[count.index]}"
}
resource "aws_network_acl_rule" "out_secure_to_transit" {
count = "${var.transit_subnet ? length(aws_subnet.transit.*.cidr_block) : 0}"
network_acl_id = "${aws_network_acl.secure.id}"
rule_number = "${count.index + 201}"
egress = true
protocol = -1
rule_action = "allow"
cidr_block = "${aws_subnet.transit.*.cidr_block[count.index]}"
}
###########
# INGRESS
###########
resource "aws_network_acl_rule" "in_secure_from_secure" {
count = "${length(aws_subnet.secure.*.cidr_block)}"
network_acl_id = "${aws_network_acl.secure.id}"
rule_number = "${count.index + 101}"
egress = false
protocol = -1
rule_action = "allow"
cidr_block = "${aws_subnet.secure.*.cidr_block[count.index]}"
}
resource "aws_network_acl_rule" "in_secure_from_private" {
count = "${length(aws_subnet.private.*.cidr_block)}"
network_acl_id = "${aws_network_acl.secure.id}"
rule_number = "${count.index + 201}"
egress = false
protocol = -1
rule_action = "allow"
cidr_block = "${aws_subnet.private.*.cidr_block[count.index]}"
}
resource "aws_network_acl_rule" "in_secure_from_transit" {
count = "${var.transit_subnet ? length(aws_subnet.transit.*.cidr_block) : 0}"
network_acl_id = "${aws_network_acl.secure.id}"
rule_number = "${count.index + 301}"
egress = false
protocol = -1
rule_action = "allow"
cidr_block = "${aws_subnet.transit.*.cidr_block[count.index]}"
}