-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
156 lines (125 loc) · 4.23 KB
/
main.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
resource "aws_eks_node_group" "main" {
count = var.create_before_destroy ? 0 : 1
cluster_name = var.cluster_name
node_group_name_prefix = var.node_group_name_prefix
node_group_name = var.node_group_name
node_role_arn = var.node_role_arn == null ? aws_iam_role.main[0].arn : var.node_role_arn
subnet_ids = var.subnet_ids
ami_type = var.ami_type
disk_size = var.disk_size
instance_types = var.instance_types
capacity_type = var.capacity_type
labels = var.labels
release_version = var.ami_release_version
version = var.kubernetes_version
force_update_version = var.force_update_version
tags = var.tags
scaling_config {
desired_size = var.desired_size
max_size = var.max_size
min_size = var.min_size
}
dynamic "taint" {
for_each = var.taints
content {
key = lookup(taint.value, "key")
value = lookup(taint.value, "value")
effect = lookup(taint.value, "effect")
}
}
dynamic "remote_access" {
for_each = var.ec2_ssh_key != null || var.source_security_group_ids != null ? ["true"] : []
content {
ec2_ssh_key = var.ec2_ssh_key
source_security_group_ids = var.source_security_group_ids
}
}
dynamic "update_config" {
for_each = length(var.update_config) == 0 ? [] : [var.update_config]
content {
max_unavailable = lookup(update_config.value, "max_unavailable", null)
max_unavailable_percentage = lookup(update_config.value, "max_unavailable_percentage", null)
}
}
dynamic "launch_template" {
for_each = length(var.launch_template) == 0 ? [] : [var.launch_template]
content {
id = lookup(launch_template.value, "id", null)
name = lookup(launch_template.value, "name", null)
version = lookup(launch_template.value, "version")
}
}
timeouts {
create = lookup(var.timeouts, "create", null)
update = lookup(var.timeouts, "update", null)
delete = lookup(var.timeouts, "delete", null)
}
lifecycle {
ignore_changes = [
scaling_config[0].desired_size
]
}
}
resource "aws_eks_node_group" "main_create_before_destroy" {
count = var.create_before_destroy ? 1 : 0
cluster_name = var.cluster_name
node_group_name_prefix = var.node_group_name_prefix
node_group_name = var.node_group_name
node_role_arn = var.node_role_arn == null ? aws_iam_role.main[0].arn : var.node_role_arn
subnet_ids = var.subnet_ids
ami_type = var.ami_type
disk_size = var.disk_size
instance_types = var.instance_types
capacity_type = var.capacity_type
labels = var.labels
release_version = var.ami_release_version
version = var.kubernetes_version
force_update_version = var.force_update_version
tags = var.tags
scaling_config {
desired_size = var.desired_size
max_size = var.max_size
min_size = var.min_size
}
dynamic "taint" {
for_each = var.taints
content {
key = lookup(taint.value, "key")
value = lookup(taint.value, "value")
effect = lookup(taint.value, "effect")
}
}
dynamic "remote_access" {
for_each = var.ec2_ssh_key != null || var.source_security_group_ids != null ? ["true"] : []
content {
ec2_ssh_key = var.ec2_ssh_key
source_security_group_ids = var.source_security_group_ids
}
}
dynamic "update_config" {
for_each = length(var.update_config) == 0 ? [] : [var.update_config]
content {
max_unavailable = lookup(update_config.value, "max_unavailable", null)
max_unavailable_percentage = lookup(update_config.value, "max_unavailable_percentage", null)
}
}
dynamic "launch_template" {
for_each = length(var.launch_template) == 0 ? [] : [var.launch_template]
content {
id = lookup(launch_template.value, "id", null)
name = lookup(launch_template.value, "name", null)
version = lookup(launch_template.value, "version")
}
}
timeouts {
create = lookup(var.timeouts, "create", null)
update = lookup(var.timeouts, "update", null)
delete = lookup(var.timeouts, "delete", null)
}
lifecycle {
create_before_destroy = true
ignore_changes = [
scaling_config[0].desired_size
]
}
}