-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathnginx-security.tf
52 lines (43 loc) · 1.22 KB
/
nginx-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
51
52
# nginx security | nginx-security.tf
# ALB Security Group: Edit to restrict access to the application
resource "aws_security_group" "aws-lb" {
name = "${var.nginx_app_name}-load-balancer"
description = "Controls access to the ALB"
vpc_id = aws_vpc.aws-vpc.id
ingress {
protocol = "tcp"
from_port = var.nginx_app_port
to_port = var.nginx_app_port
cidr_blocks = [var.app_sources_cidr]
}
egress {
protocol = "-1"
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "${var.nginx_app_name}-load-balancer"
}
}
# Traffic to the ECS cluster from the ALB
resource "aws_security_group" "aws-ecs-tasks" {
name = "${var.nginx_app_name}-ecs-tasks"
description = "Allow inbound access from the ALB only"
vpc_id = aws_vpc.aws-vpc.id
ingress {
protocol = "tcp"
from_port = var.nginx_app_port
to_port = var.nginx_app_port
security_groups = [aws_security_group.aws-lb.id]
}
egress {
protocol = "-1"
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "${var.nginx_app_name}-ecs-tasks"
}
}