mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-01-15 16:23:58 +01:00
NOTES: Managed Node Groups now support Launch Templates. The Launch Template it self is not managed by this module, so you have to create it by your self and pass it's id to this module. See docs and [`examples/launch_templates_with_managed_node_groups/`](https://github.com/terraform-aws-modules/terraform-aws-eks/tree/master/examples/launch_templates_with_managed_node_group) for more details.
65 lines
2.0 KiB
HCL
65 lines
2.0 KiB
HCL
resource "aws_eks_node_group" "workers" {
|
|
for_each = local.node_groups_expanded
|
|
|
|
node_group_name = lookup(each.value, "name", join("-", [var.cluster_name, each.key, random_pet.node_groups[each.key].id]))
|
|
|
|
cluster_name = var.cluster_name
|
|
node_role_arn = each.value["iam_role_arn"]
|
|
subnet_ids = each.value["subnets"]
|
|
|
|
scaling_config {
|
|
desired_size = each.value["desired_capacity"]
|
|
max_size = each.value["max_capacity"]
|
|
min_size = each.value["min_capacity"]
|
|
}
|
|
|
|
ami_type = lookup(each.value, "ami_type", null)
|
|
disk_size = lookup(each.value, "disk_size", null)
|
|
instance_types = each.value["launch_template_id"] != "" ? [] : [each.value["instance_type"]]
|
|
release_version = lookup(each.value, "ami_release_version", null)
|
|
|
|
dynamic "remote_access" {
|
|
for_each = each.value["key_name"] != "" ? [{
|
|
ec2_ssh_key = each.value["key_name"]
|
|
source_security_group_ids = lookup(each.value, "source_security_group_ids", [])
|
|
}] : []
|
|
|
|
content {
|
|
ec2_ssh_key = remote_access.value["ec2_ssh_key"]
|
|
source_security_group_ids = remote_access.value["source_security_group_ids"]
|
|
}
|
|
}
|
|
|
|
dynamic "launch_template" {
|
|
for_each = each.value["launch_template_id"] != "" ? [{
|
|
id = each.value["launch_template_id"]
|
|
version = each.value["launch_template_version"]
|
|
}] : []
|
|
|
|
content {
|
|
id = launch_template.value["id"]
|
|
version = launch_template.value["version"]
|
|
}
|
|
}
|
|
|
|
version = lookup(each.value, "version", null)
|
|
|
|
labels = merge(
|
|
lookup(var.node_groups_defaults, "k8s_labels", {}),
|
|
lookup(var.node_groups[each.key], "k8s_labels", {})
|
|
)
|
|
|
|
tags = merge(
|
|
var.tags,
|
|
lookup(var.node_groups_defaults, "additional_tags", {}),
|
|
lookup(var.node_groups[each.key], "additional_tags", {}),
|
|
)
|
|
|
|
lifecycle {
|
|
create_before_destroy = true
|
|
ignore_changes = [scaling_config.0.desired_size]
|
|
}
|
|
|
|
depends_on = [var.ng_depends_on]
|
|
}
|