From 6308009bf1552a48edefdf788c00747b10715a20 Mon Sep 17 00:00:00 2001 From: Albin Gustavsson Date: Thu, 6 Jul 2023 15:33:37 +0200 Subject: [PATCH] Add option to set instance_type on the launch template This allows setting the instance type on the launch template rather than the EKS Managed node group. This is useful because it is not possible to change the instance types set on a managed node groups after creation. The suggested way to work around this is to simply define the instance type in the launch template. https://github.com/aws/containers-roadmap/issues/746#issuecomment-675099508 --- modules/eks-managed-node-group/main.tf | 2 ++ modules/eks-managed-node-group/variables.tf | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/eks-managed-node-group/main.tf b/modules/eks-managed-node-group/main.tf index 1d3fe81698b..035b428d6cf 100644 --- a/modules/eks-managed-node-group/main.tf +++ b/modules/eks-managed-node-group/main.tf @@ -170,6 +170,8 @@ resource "aws_launch_template" "this" { } } + instance_type = var.instance_type + # # Set on node group instead # instance_type = var.launch_template_instance_type kernel_id = var.kernel_id diff --git a/modules/eks-managed-node-group/variables.tf b/modules/eks-managed-node-group/variables.tf index 197cd28c958..161d9407500 100644 --- a/modules/eks-managed-node-group/variables.tf +++ b/modules/eks-managed-node-group/variables.tf @@ -222,6 +222,12 @@ variable "instance_market_options" { default = {} } +variable "instance_type" { + description = "Set of instance type associated with the Launch Template. Conflicts with `instance_types`" + type = string + default = null +} + variable "maintenance_options" { description = "The maintenance options for the instance" type = any @@ -351,7 +357,7 @@ variable "force_update_version" { } variable "instance_types" { - description = "Set of instance types associated with the EKS Node Group. Defaults to `[\"t3.medium\"]`" + description = "Set of instance types associated with the EKS Node Group. Defaults to `[\"t3.medium\"]`. Conflicts with `instance_types`" type = list(string) default = null }