-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfirewall.tf
61 lines (52 loc) · 1.62 KB
/
firewall.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
/**
# Creating a security group for load balancers
resource "aws_security_group" "entry-point" {
for_each = toset(local.configuration.sdlc.environments)
name = "entry-point-from-world"
vpc_id = data.aws_vpc.network.id
ingress {
from_port = 80 # Allowing traffic in from port 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # Allowing traffic in from all sources
}
ingress {
from_port = 443 # Allowing traffic in from port 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # Allowing traffic in from all sources
}
egress {
from_port = 0 # Allowing any incoming port
to_port = 0 # Allowing any outgoing port
protocol = "-1" # Allowing any outgoing protocol
cidr_blocks = ["0.0.0.0/0"] # Allowing traffic out to all IP addresses
}
tags = {
Name = "Entry Point from World"
}
}
resource "aws_security_group" "alb-access" {
for_each = toset(local.configuration.sdlc.environments)
name = "alb-access"
vpc_id = data.aws_vpc.network.id
ingress {
from_port = 0
to_port = 0
protocol = "-1"
# Only allowing traffic in from load balancers security group
security_groups = [
aws_security_group.entry-point[each.value].id,
]
}
egress {
from_port = 0 # Allowing any incoming port
to_port = 0 # Allowing any outgoing port
protocol = "-1" # Allowing any outgoing protocol
cidr_blocks = ["0.0.0.0/0"] # Allowing traffic out to all IP addresses
}
tags = {
Name = "ALB Access"
}
}
/**/