-
Notifications
You must be signed in to change notification settings - Fork 6
/
spectro-cluster-eks.tf
220 lines (195 loc) · 9.64 KB
/
spectro-cluster-eks.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
resource "spectrocloud_cluster_eks" "this" {
for_each = { for x in local.eks_clusters : x.name => x }
name = each.value.name
context = try(each.value.context, "project")
apply_setting = try(each.value.apply_setting, "DownloadAndInstall")
tags = try(each.value.tags, [])
skip_completion = try(each.value.skip_completion, false)
description = try(each.value.description, "")
cloud_config {
region = each.value.cloud_config.aws_region
vpc_id = can(each.value.cloud_config.aws_vpc_id) ? each.value.cloud_config.aws_vpc_id : null
ssh_key_name = try(each.value.cloud_config.ssh_key_name, null)
az_subnets = can(each.value.cloud_config.eks_subnets) ? each.value.cloud_config.eks_subnets : null
azs = []
endpoint_access = each.value.cloud_config.endpoint_access
public_access_cidrs = try(each.value.cloud_config.public_access_cidrs, [])
private_access_cidrs = try(each.value.cloud_config.private_access_cidrs, [])
encryption_config_arn = can(each.value.cloud_config.encryption_config_arn) ? each.value.cloud_config.encryption_config_arn : null
}
os_patch_schedule = can(each.value.os_patch_schedule) ? each.value.os_patch_schedule : null
dynamic "cluster_rbac_binding" {
for_each = try(each.value.cluster_rbac_binding, [])
content {
type = cluster_rbac_binding.value.type
namespace = try(cluster_rbac_binding.value.namespace, "")
role = {
kind = cluster_rbac_binding.value.role.kind
name = cluster_rbac_binding.value.role.name
}
dynamic "subjects" {
for_each = try(cluster_rbac_binding.value.subjects, [])
content {
type = subjects.value.type
name = subjects.value.name
namespace = try(subjects.value.namespace, "")
}
}
}
}
dynamic "namespaces" {
for_each = try(each.value.namespaces, [])
content {
name = namespaces.value.name
resource_allocation = {
cpu_cores = try(namespaces.value.resource_allocation.cpu_cores, "")
memory_MiB = try(namespaces.value.resource_allocation.memory_MiB, "")
}
}
}
cluster_profile {
id = (local.profile_map[format("%s%%%s%%%s",
each.value.profiles.infra.name,
try(each.value.profiles.infra.version, "1.0.0"),
try(each.value.profiles.infra.context, "project"))].id)
dynamic "pack" {
for_each = try(each.value.profiles.infra.packs, [])
content {
name = pack.value.name
tag = try(pack.value.version, "")
registry_uid = try(local.all_registry_map[pack.value.registry][0], "")
type = (try(pack.value.is_manifest_pack, false)) ? "manifest" : "spectro"
values = "${(try(pack.value.is_manifest_pack, false)) ?
local.cluster-profile-pack-map[format("%s%%%s%%%s$%s", each.value.profiles.infra.name, try(each.value.profiles.infra.version, "1.0.0"), try(each.value.profiles.infra.context, "project"), pack.value.name)].values :
(pack.value.override_type == "values") ?
pack.value.values :
(pack.value.override_type == "params" ?
local.infra-pack-params-replaced[format("%s$%s%%%s%%%s$%s", each.value.name, each.value.profiles.infra.name, try(each.value.profiles.infra.version, "1.0.0"), try(each.value.profiles.infra.context, "project"), pack.value.name)] :
local.infra-pack-template-params-replaced[format("%s$%s%%%s%%%s$%s", each.value.name, each.value.profiles.infra.name, try(each.value.profiles.infra.version, "1.0.0"), try(each.value.profiles.infra.context, "project"), pack.value.name)])
}"
dynamic "manifest" {
for_each = try([local.infra_pack_manifests[format("%s$%s%%%s%%%s$%s", each.value.name, each.value.profiles.infra.name, try(each.value.profiles.infra.version, "1.0.0"), try(each.value.profile.infra.context, "project"), pack.value.name)]], [])
content {
name = manifest.value.name
content = manifest.value.content
}
}
}
}
}
dynamic "cluster_profile" {
for_each = try(each.value.profiles.addons, [])
content {
id = (local.profile_map[format("%s%%%s%%%s",
cluster_profile.value.name,
try(cluster_profile.value.version, "1.0.0"),
try(cluster_profile.value.context, "project"))].id)
dynamic "pack" {
for_each = try(cluster_profile.value.packs, [])
content {
name = pack.value.name
tag = try(pack.value.version, "")
registry_uid = try(local.all_registry_map[pack.value.registry][0], "")
type = (try(pack.value.is_manifest_pack, false)) ? "manifest" : "spectro"
values = "${(try(pack.value.is_manifest_pack, false)) ?
local.cluster-profile-pack-map[format("%s%%%s%%%s$%s", cluster_profile.value.name, try(cluster_profile.value.version, "1.0.0"), try(cluster_profile.value.context, "project"), pack.value.name)].values :
(pack.value.override_type == "values") ?
pack.value.values :
(pack.value.override_type == "params" ?
local.addon_pack_params_replaced[format("%s$%s%%%s%%%s$%s", each.value.name, cluster_profile.value.name, try(cluster_profile.value.version, "1.0.0"), try(cluster_profile.value.context, "project"), pack.value.name)] :
local.addon_pack_template_params_replaced[format("%s$%s%%%s%%%s$%s", each.value.name, cluster_profile.value.name, try(cluster_profile.value.version, "1.0.0"), try(cluster_profile.value.context, "project"), pack.value.name)])
}"
dynamic "manifest" {
for_each = try(local.addon_pack_manifests[format("%s$%s%%%s%%%s$%s", each.value.name, cluster_profile.value.name, try(cluster_profile.value.version, "1.0.0"), try(cluster_profile.value.context, "project"), pack.value.name)], [])
content {
name = manifest.value.name
content = manifest.value.content
}
}
}
}
}
}
cloud_account_id = lookup(local.aws_cloud_account_names, each.value.cloud_account, null)
#cloud_account_id = data.spectrocloud_cloudaccount_aws.this[each.value.cloud_account].id
dynamic "machine_pool" {
for_each = each.value.node_groups
content {
name = machine_pool.value.name
update_strategy = try(machine_pool.value.update_strategy, "RollingUpdateScaleOut")
count = machine_pool.value.count
# The min and max settings for EKS will only be taken into account if the autoscaler pack is added to the cluster. By default, both min and max values are set to 0. To activate autoscaling, assign the desired sizes to both the minimum and maximum settings.
min = try(machine_pool.value.min, 0)
max = try(machine_pool.value.max, 0)
capacity_type = try(machine_pool.value.capacity_type, "on-demand")
instance_type = machine_pool.value.instance_type
az_subnets = can(machine_pool.value.worker_subnets) ? machine_pool.value.worker_subnets : null
disk_size_gb = machine_pool.value.disk_size_gb
azs = []
additional_labels = try(machine_pool.value.additional_labels, tomap({}))
dynamic "node" {
for_each = try(machine_pool.value.node, [])
content {
node_id = node.value.node_id
action = node.value.action
}
}
dynamic "taints" {
for_each = try(machine_pool.value.taints, [])
content {
key = taints.value.key
value = taints.value.value
effect = taints.value.effect
}
}
dynamic "eks_launch_template" {
for_each = try(machine_pool.value.eks_launch_template, null) != null ? [machine_pool.value.eks_launch_template] : []
content {
ami_id = try(eks_launch_template.value.ami_id, null)
root_volume_type = try(eks_launch_template.value.root_volume_type, null)
root_volume_iops = try(eks_launch_template.value.root_volume_iops, null)
root_volume_throughput = try(eks_launch_template.value.root_volume_throughput, null)
additional_security_groups = try(eks_launch_template.value.additional_security_groups, null)
}
}
}
}
dynamic "fargate_profile" {
for_each = try(each.value.fargate_profiles, [])
content {
name = fargate_profile.value.name
subnets = can(fargate_profile.value.subnets) ? fargate_profile.value.subnets : null
additional_tags = fargate_profile.value.additional_tags
dynamic "selector" {
for_each = fargate_profile.value.selectors
content {
namespace = selector.value.namespace
labels = selector.value.labels
}
}
}
}
dynamic "backup_policy" {
for_each = try(tolist([each.value.backup_policy]), [])
content {
schedule = backup_policy.value.schedule
backup_location_id = local.bsl_map[backup_policy.value.backup_location]
prefix = backup_policy.value.prefix
expiry_in_hour = 7200
include_disks = true
include_cluster_resources = true
}
}
dynamic "scan_policy" {
for_each = try(tolist([each.value.scan_policy]), [])
content {
configuration_scan_schedule = scan_policy.value.configuration_scan_schedule
penetration_scan_schedule = scan_policy.value.penetration_scan_schedule
conformance_scan_schedule = scan_policy.value.conformance_scan_schedule
}
}
timeouts {
create = try(each.value.timeouts.create, "60m")
delete = try(each.value.timeouts.delete, "60m")
}
}