Skip to content

Commit

Permalink
fix: Allow leaving out default values and adding more fields to node …
Browse files Browse the repository at this point in the history
…groups (#269)
  • Loading branch information
msvticket authored Jun 7, 2021
1 parent 2aedebe commit a9924e8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 40 deletions.
29 changes: 12 additions & 17 deletions modules/cluster/local.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ locals {
project = data.aws_caller_identity.current.account_id

node_group_defaults = {
ami_type = var.node_group_ami
disk_size = var.node_group_disk_size
desired_capacity = var.desired_node_count
max_capacity = var.max_node_count
min_capacity = var.min_node_count
instance_types = [var.node_machine_type]

launch_template_id = null
launch_template_version = null

Expand All @@ -32,27 +39,15 @@ locals {
}
}

node_groups_extended = length(var.node_groups) > 0 ? { for k, v in var.node_groups : k => merge(
node_groups_extended = { for k, v in var.node_groups : k => merge(
local.node_group_defaults,
v,
{
contains(keys(v), "k8s_labels") ? {
# Deep merge isn't a thing in terraform, yet, so we commit these atrocities.
k8s_labels = merge(
local.node_group_defaults["k8s_labels"],
v["k8s_labels"],
)
},
) } : {
eks-jx-node-group = merge(
{
ami_type = var.node_group_ami
disk_size = var.node_group_disk_size
desired_capacity = var.desired_node_count
max_capacity = var.max_node_count
min_capacity = var.min_node_count
instance_types = [var.node_machine_type]
},
local.node_group_defaults
)
}
)
} : {},
)}
}
12 changes: 1 addition & 11 deletions modules/cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,7 @@ variable "spot_price" {

variable "node_groups" {
description = "List of node groups to be created"
type = map(object({
ami_type = string
disk_size = number
desired_capacity = number
max_capacity = number
min_capacity = number
instance_types = list(string)
launch_template_id = string
launch_template_version = string
k8s_labels = map(string)
}))
type = any
default = {}
}

Expand Down
14 changes: 2 additions & 12 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,8 @@ variable "node_group_disk_size" {

variable "node_groups_managed" {
description = "List of managed node groups to be created and their respective settings"
type = map(object({
ami_type = string
disk_size = number
desired_capacity = number
max_capacity = number
min_capacity = number
instance_types = list(string)
launch_template_id = string
launch_template_version = string
k8s_labels = map(string)
}))
default = {}
type = any
default = {eks-jx-node-group = {}}
}

variable "key_name" {
Expand Down

0 comments on commit a9924e8

Please sign in to comment.