-
Notifications
You must be signed in to change notification settings - Fork 3
/
23-security-group.tf
62 lines (51 loc) · 1.16 KB
/
23-security-group.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
# security group
resource "aws_security_group" "public" {
name = format("%s-public", local.full_name)
description = "controls access to the ALB"
vpc_id = var.vpc_id
ingress {
protocol = "tcp"
from_port = "80"
to_port = "80"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
protocol = "tcp"
from_port = "443"
to_port = "443"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = local.full_name
Service = local.name
Cluster = var.cluster_name
}
}
resource "aws_security_group" "private" {
name = format("%s-private", local.full_name)
description = "allow inbound access from the ALB only"
vpc_id = var.vpc_id
ingress {
protocol = "tcp"
from_port = var.port
to_port = var.port
security_groups = [aws_security_group.public.id]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = local.full_name
Service = local.name
Cluster = var.cluster_name
}
}