-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path25-cluster-sg.tf
73 lines (60 loc) · 2.1 KB
/
25-cluster-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
71
72
73
# cluster sg
# https://docs.aws.amazon.com/ko_kr/eks/latest/userguide/sec-group-reqs.html
resource "aws_security_group" "cluster" {
name = local.cluster_name
description = "Cluster communication with Worker Nodes"
vpc_id = var.vpc_id
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = var.ip_family == "ipv6" ? ["::/0"] : null
}
# revoke_rules_on_delete = true
tags = merge(
local.tags,
{
"Name" = local.cluster_name
},
)
}
resource "aws_security_group_rule" "cluster_worker" {
type = "ingress"
description = format("%s - worker 443", local.cluster_name)
security_group_id = aws_security_group.cluster.id
from_port = 443
to_port = 443
protocol = "TCP"
source_security_group_id = aws_security_group.worker.id
}
resource "aws_security_group_rule" "cluster_sslvpn" {
count = var.sslvpn_name != "" ? 1 : 0
type = "ingress"
description = format("%s - sslvpn 443", local.cluster_name)
security_group_id = aws_security_group.cluster.id
from_port = 443
to_port = 443
protocol = "TCP"
prefix_list_ids = data.aws_ec2_managed_prefix_list.sslvpn.*.id
}
resource "aws_security_group_rule" "cluster_prefix_list" {
count = length(var.allow_prefix_list_ids)
type = "ingress"
description = format("%s - prefix_list 443", local.cluster_name)
security_group_id = aws_security_group.cluster.id
from_port = 443
to_port = 443
protocol = "TCP"
prefix_list_ids = [var.allow_prefix_list_ids[count.index]]
}
resource "aws_security_group_rule" "cluster_cidr" {
count = length(var.allow_cidr_cluster)
type = "ingress"
description = format("%s - cidr 443", local.cluster_name)
security_group_id = aws_security_group.cluster.id
from_port = 443
to_port = 443
protocol = "TCP"
cidr_blocks = [var.allow_cidr_cluster[count.index]]
}