-
Notifications
You must be signed in to change notification settings - Fork 0
/
security.tf
50 lines (42 loc) · 1.2 KB
/
security.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
# =========== Creating security group for load balancer
resource "aws_security_group" "lb" {
name = "nginx-load-balancer-security-group"
description = "Allow http to be accepted and forwared to 80"
vpc_id = aws_vpc.main.id
# inbound rule accept 80:80
ingress {
protocol = "tcp"
description = "Accepting 80 and forward to 80"
from_port = var.app_type.port
to_port = var.app_type.port
cidr_blocks = ["0.0.0.0/0"]
}
# outbound rule
egress {
protocol = "-1" # set to all
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
}
# =========== Creating security group for ecs
resource "aws_security_group" "ecs" {
name = "nginx-ecs-tasks-security-group"
description = "Limiting access of ecs to get from alb only"
vpc_id = aws_vpc.main.id
# inbound rule accept 80:80 for lb only
ingress {
protocol = "tcp"
description = "Accepting 80 and forward to 80"
from_port = var.app_type.port
to_port = var.app_type.port
security_groups = [aws_security_group.lb.id]
}
# outbound rule
egress {
protocol = "-1" # set to all
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
}