This repository has been archived by the owner on May 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheks-worker-sg.tf
70 lines (62 loc) · 2.82 KB
/
eks-worker-sg.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
70
resource "aws_security_group" "eks-node" {
name = "terraform-eks-node-${var.cluster-name}"
description = "Security group for all nodes in the cluster"
vpc_id = var.vpc["create"] ? join(",", aws_vpc.eks.*.id) : var.vpc["vpc_id"]
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = merge({ "Name" = "terraform-eks-node-${var.cluster-name}", "kubernetes.io/cluster/${var.cluster-name}" = "owned" }, local.common_tags, var.custom_tags)
}
resource "aws_security_group_rule" "eks-node-ingress-self" {
description = "Allow node to communicate with each other"
from_port = 0
protocol = "-1"
security_group_id = aws_security_group.eks-node.id
to_port = 65535
type = "ingress"
self = true
}
resource "aws_security_group_rule" "eks-node-ingress-cluster" {
description = "Allow worker Kubelets and pods to receive communication from the cluster control plane"
from_port = 1025
protocol = "tcp"
security_group_id = aws_security_group.eks-node.id
source_security_group_id = aws_security_group.eks-cluster.id
to_port = 65535
type = "ingress"
}
resource "aws_security_group_rule" "eks-node-ingress-cluster-443" {
description = "Allow worker Kubelets and pods to receive communication from the cluster control plane for metrics server"
from_port = 443
protocol = "tcp"
security_group_id = aws_security_group.eks-node.id
source_security_group_id = aws_security_group.eks-cluster.id
to_port = 443
type = "ingress"
}
resource "aws_security_group_rule" "eks-node-ingress-cluster-ssh" {
count = var.ssh_remote_security_group_id == "" ? 0 : 1
description = "Allow worker Kubelets and pods to receive SSH communication from a remote security group"
from_port = 22
protocol = "tcp"
security_group_id = aws_security_group.eks-node.id
source_security_group_id = var.ssh_remote_security_group_id
to_port = 22
type = "ingress"
}
resource "aws_security_group_rule" "eks-node-ingress-cluster-ssh-bastion" {
count = var.bastion["create"] ? 1 : 0
description = "Allow worker Kubelets and pods to receive SSH communication from a remote security group"
from_port = 22
protocol = "tcp"
security_group_id = aws_security_group.eks-node.id
source_security_group_id = aws_security_group.bastion[count.index].id
to_port = 22
type = "ingress"
}
output "eks-node-sg" {
value = aws_security_group.eks-node.id
}