diff --git a/examples/node-groups/self-managed-node-groups/main.tf b/examples/node-groups/self-managed-node-groups/main.tf index d064c8a502..8d972b974a 100644 --- a/examples/node-groups/self-managed-node-groups/main.tf +++ b/examples/node-groups/self-managed-node-groups/main.tf @@ -52,6 +52,14 @@ module "eks_blueprints" { node_group_name = "self_mg4" launch_template_os = "amazonlinux2eks" subnet_ids = module.vpc.private_subnets + + placement = { + affinity = null + availability_zone = null + group_name = null + host_id = null + tenancy = "dedicated" + } } self_mg5 = { node_group_name = "self_mg5" # Name is used to create a dedicated IAM role for each node group and adds to AWS-AUTH config map diff --git a/modules/aws-eks-self-managed-node-groups/self-managed-launch-templates.tf b/modules/aws-eks-self-managed-node-groups/self-managed-launch-templates.tf index 880d25dd18..fbed32f8d7 100644 --- a/modules/aws-eks-self-managed-node-groups/self-managed-launch-templates.tf +++ b/modules/aws-eks-self-managed-node-groups/self-managed-launch-templates.tf @@ -23,6 +23,7 @@ module "launch_template_self_managed_ng" { http_put_response_hop_limit = try(var.self_managed_ng.http_put_response_hop_limit, 2) http_protocol_ipv6 = try(var.self_managed_ng.http_protocol_ipv6, null) instance_metadata_tags = try(var.self_managed_ng.instance_metadata_tags, null) + placement = try(var.self_managed_ng.placement, null) service_ipv6_cidr = var.context.service_ipv6_cidr service_ipv4_cidr = var.context.service_ipv4_cidr diff --git a/modules/launch-templates/main.tf b/modules/launch-templates/main.tf index c51fa885ea..500a2ebfcb 100644 --- a/modules/launch-templates/main.tf +++ b/modules/launch-templates/main.tf @@ -64,6 +64,17 @@ resource "aws_launch_template" "this" { } } + dynamic "placement" { + for_each = try(each.value.placement, null) != null ? [each.value.placement] : [] + content { + affinity = lookup(placement.value, "affinity", null) + availability_zone = lookup(placement.value, "availability_zone", null) + group_name = lookup(placement.value, "group_name", null) + host_id = lookup(placement.value, "host_id", null) + tenancy = lookup(placement.value, "tenancy", null) + } + } + vpc_security_group_ids = try(each.value.vpc_security_group_ids, null) dynamic "network_interfaces" {