-
Notifications
You must be signed in to change notification settings - Fork 2
/
security.tf
69 lines (61 loc) · 1.65 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
################################################
## This file contains security groups required #
## for ECS to ingress and egress with outside #
################################################
resource "aws_security_group" "alb-sg" {
name = "alb-ingress"
description = "ALB Ingress from outside subnet"
vpc_id = "${aws_vpc.demo-vpc.id}"
ingress {
protocol = "tcp"
from_port = 80
to_port = 80
cidr_blocks = ["${var.internet_cidr}"]
}
ingress {
protocol = "tcp"
from_port = 8080
to_port = 8080
cidr_blocks = ["${var.internet_cidr}"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["${var.internet_cidr}"]
}
}
resource "aws_security_group" "website-sg" {
name = "ingress-to-website"
description = "Ingress from ALB to website"
vpc_id = "${aws_vpc.demo-vpc.id}"
ingress {
protocol = "tcp"
from_port = "${var.website_port}"
to_port = "${var.website_port}"
security_groups = ["${aws_security_group.alb-sg.id}"]
}
egress {
protocol = "-1"
from_port = 0
to_port = 0
cidr_blocks = ["${var.internet_cidr}"]
}
}
resource "aws_security_group" "jumpdude-sg" {
name = "ingress-to-game"
description = "Ingress from ALB to game"
vpc_id = "${aws_vpc.demo-vpc.id}"
ingress {
protocol = "tcp"
from_port = "${var.game_port}"
to_port = "${var.game_port}"
security_groups = ["${aws_security_group.alb-sg.id}"]
}
egress {
protocol = "-1"
from_port = 0
to_port = 0
cidr_blocks = ["${var.internet_cidr}"]
}
}