-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecurity.tf
47 lines (45 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
# allow all ingress from this security group
resource "aws_security_group" "ingress_sg" {
vpc_id = data.aws_vpc.default.id
ingress {
self = true
from_port = 0
to_port = 0
protocol = "-1"
}
tags = {
Name = format("%s-%s", var.cluster_name, "ingress_sg"),
Tag = var.cluster_name,
Owner = basename(data.aws_caller_identity.current.arn),
}
}
# allow all ingress from the client machine
resource "aws_security_group" "ingress_client" {
vpc_id = data.aws_vpc.default.id
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [format("%s/%s", data.external.client_info.result["ip"], 32)]
}
tags = {
Name = format("%s-%s", var.cluster_name, "ingress_client"),
Tag = var.cluster_name,
Owner = basename(data.aws_caller_identity.current.arn),
}
}
# allow all egress
resource "aws_security_group" "egress_all" {
vpc_id = data.aws_vpc.default.id
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = format("%s-%s", var.cluster_name, "egress_all"),
Tag = var.cluster_name,
Owner = basename(data.aws_caller_identity.current.arn),
}
}