-
Notifications
You must be signed in to change notification settings - Fork 0
/
security-groups.tf
91 lines (82 loc) · 2.62 KB
/
security-groups.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
#
# HTTP from world (for Load Balancer)
#
resource "aws_security_group" "http_world" {
name = "http-from-world"
description = "Full external access to http(s)"
vpc_id = data.aws_vpc.default.id
}
resource "aws_security_group_rule" "http_world" {
cidr_blocks = ["0.0.0.0/0"]
from_port = 80
protocol = "tcp"
security_group_id = aws_security_group.http_world.id
to_port = 80
type = "ingress"
}
resource "aws_security_group_rule" "outbound_world" {
cidr_blocks = ["0.0.0.0/0"]
from_port = 0
protocol = "-1"
security_group_id = aws_security_group.http_world.id
to_port = 0
type = "egress"
}
#
# HTTP from Load Balancer (for Task)
#
resource "aws_security_group" "task" {
name = "lb-to-task"
description = "Allow load balancer to talk to task"
vpc_id = data.aws_vpc.default.id
}
resource "aws_security_group_rule" "task" {
from_port = 80
protocol = "tcp"
security_group_id = aws_security_group.task.id
source_security_group_id = aws_security_group.http_world.id
to_port = 80
type = "ingress"
}
resource "aws_security_group_rule" "outbound_task" {
cidr_blocks = ["0.0.0.0/0"]
from_port = 0
protocol = "-1"
security_group_id = aws_security_group.task.id
to_port = 0
type = "egress"
}
## Allow access from world (for diagnostics)
#resource "aws_security_group_rule" "http_world_task" {
# cidr_blocks = ["0.0.0.0/0"]
# from_port = 80
# protocol = "tcp"
# security_group_id = aws_security_group.task.id
# to_port = 80
# type = "ingress"
#}
#
# EFS from EFS Tagged (for EFS endpoints)
#
resource "aws_security_group" "efs" {
name = "efs-from-task"
description = "Allow EFS traffic from the VPC"
vpc_id = data.aws_vpc.default.id
}
resource "aws_security_group_rule" "efs" {
from_port = 2049 #nfs/efs port
protocol = "tcp"
security_group_id = aws_security_group.efs.id
source_security_group_id = aws_security_group.task.id
to_port = 2049 #nfs/efs port
type = "ingress"
}
## Allow access from VPC (for diagnostics and loading data)
#resource "aws_security_group_rule" "efs_vpc" {
# cidr_blocks = [data.aws_vpc.default.cidr_block]
# from_port = 2049 #nfs/efs port
# protocol = "tcp"
# security_group_id = aws_security_group.efs.id
# to_port = 2049 #nfs/efs port
# type = "ingress"
#}