From 3f50fcea2cb97b2935cb294dd67e61544e1646f2 Mon Sep 17 00:00:00 2001 From: Loren Gordon <8457307+lorengordon@users.noreply.github.com> Date: Fri, 12 Sep 2025 13:49:16 -0700 Subject: [PATCH 1/5] When compute_mode is provided, also configure elastic_load_balancing and storage_config --- main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index 8ea8629b8d..4d6b0adeb1 100644 --- a/main.tf +++ b/main.tf @@ -58,7 +58,7 @@ resource "aws_eks_cluster" "this" { } dynamic "compute_config" { - for_each = var.compute_config != null ? [var.compute_config] : [] + for_each = var.compute_config[*] content { enabled = compute_config.value.enabled @@ -81,7 +81,7 @@ resource "aws_eks_cluster" "this" { content { dynamic "elastic_load_balancing" { - for_each = local.auto_mode_enabled ? [1] : [] + for_each = var.compute_config[*] content { enabled = local.auto_mode_enabled @@ -148,7 +148,7 @@ resource "aws_eks_cluster" "this" { } dynamic "storage_config" { - for_each = local.auto_mode_enabled ? [1] : [] + for_each = var.compute_config[*] content { block_storage { From c209337ec1424ed82937f26c0cc4a288b3b22c87 Mon Sep 17 00:00:00 2001 From: Loren Gordon <8457307+lorengordon@users.noreply.github.com> Date: Fri, 12 Sep 2025 14:00:02 -0700 Subject: [PATCH 2/5] Empties compute_config.node_pools when auto mode is disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When disabling auto mode, fixes the apply-time error: ``` │ Error: updating EKS Cluster (ex-eks-auto-mode) compute config: operation error EKS: UpdateClusterConfig, https response error StatusCode: 400, RequestID: f895a875-7bbf-4003-92e0-3aca4bc9d415, InvalidParameterException: When Compute Config nodeRoleArn is null or empty, nodePool list cannot be populated. ``` --- main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 4d6b0adeb1..b5280b49a1 100644 --- a/main.tf +++ b/main.tf @@ -62,7 +62,7 @@ resource "aws_eks_cluster" "this" { content { enabled = compute_config.value.enabled - node_pools = compute_config.value.node_pools + node_pools = compute_config.value.enabled ? compute_config.value.node_pools : [] node_role_arn = compute_config.value.node_pools != null ? try(aws_iam_role.eks_auto[0].arn, compute_config.value.node_role_arn) : null } } From 076e62db64cf11e7b666c9270cc40d6f50595a3f Mon Sep 17 00:00:00 2001 From: Loren Gordon <8457307+lorengordon@users.noreply.github.com> Date: Fri, 12 Sep 2025 14:11:10 -0700 Subject: [PATCH 3/5] Nulls compute_config.node_role_arn when node_pools is empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the apply time error: ``` │ Error: updating EKS Cluster (ex-eks-auto-mode) compute config: operation error EKS: UpdateClusterConfig, https response error StatusCode: 400, RequestID: 93002327-da4d-47e2-8389-518b03e8aa60, InvalidParameterException: When Compute Config nodeRoleArn is not null or empty, nodePool value(s) must be provided. ``` --- main.tf | 2 +- variables.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index b5280b49a1..423ce6aba5 100644 --- a/main.tf +++ b/main.tf @@ -63,7 +63,7 @@ resource "aws_eks_cluster" "this" { content { enabled = compute_config.value.enabled node_pools = compute_config.value.enabled ? compute_config.value.node_pools : [] - node_role_arn = compute_config.value.node_pools != null ? try(aws_iam_role.eks_auto[0].arn, compute_config.value.node_role_arn) : null + node_role_arn = compute_config.value.enabled ? (length(compute_config.value.node_pools) > 0 ? try(aws_iam_role.eks_auto[0].arn, compute_config.value.node_role_arn) : null) : null } } diff --git a/variables.tf b/variables.tf index 9647017980..70590ce98a 100644 --- a/variables.tf +++ b/variables.tf @@ -66,7 +66,7 @@ variable "compute_config" { description = "Configuration block for the cluster compute configuration" type = object({ enabled = optional(bool, false) - node_pools = optional(list(string)) + node_pools = optional(list(string), []) node_role_arn = optional(string) }) default = null From 354f77eecc9bf5974330b550088f50d9e0dd39be Mon Sep 17 00:00:00 2001 From: Loren Gordon <8457307+lorengordon@users.noreply.github.com> Date: Mon, 15 Sep 2025 06:58:41 -0700 Subject: [PATCH 4/5] Adds example for auto mode config without built-in node pools --- examples/eks-auto-mode/main.tf | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/examples/eks-auto-mode/main.tf b/examples/eks-auto-mode/main.tf index e00b825f63..343e340a42 100644 --- a/examples/eks-auto-mode/main.tf +++ b/examples/eks-auto-mode/main.tf @@ -50,6 +50,27 @@ module "eks" { tags = local.tags } +module "eks_custom_node_pools" { + source = "../.." + + name = "${local.name}-cnp" + kubernetes_version = local.kubernetes_version + endpoint_public_access = true + deletion_protection = true + + enable_cluster_creator_admin_permissions = true + + compute_config = { + enabled = true + node_pools = [] + } + + vpc_id = module.vpc.vpc_id + subnet_ids = module.vpc.private_subnets + + tags = local.tags +} + module "disabled_eks" { source = "../.." From 3531c933c524705bb0fd0287299a001c56ab9e0e Mon Sep 17 00:00:00 2001 From: Loren Gordon <8457307+lorengordon@users.noreply.github.com> Date: Mon, 15 Sep 2025 07:07:42 -0700 Subject: [PATCH 5/5] Updates readmes to match variable and module definitions --- README.md | 2 +- examples/eks-auto-mode/README.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ec22fdd351..7cafbf86c0 100644 --- a/README.md +++ b/README.md @@ -393,7 +393,7 @@ We are grateful to the community for contributing bugfixes and improvements! Ple | [cloudwatch\_log\_group\_retention\_in\_days](#input\_cloudwatch\_log\_group\_retention\_in\_days) | Number of days to retain log events. Default retention - 90 days | `number` | `90` | no | | [cloudwatch\_log\_group\_tags](#input\_cloudwatch\_log\_group\_tags) | A map of additional tags to add to the cloudwatch log group created | `map(string)` | `{}` | no | | [cluster\_tags](#input\_cluster\_tags) | A map of additional tags to add to the cluster | `map(string)` | `{}` | no | -| [compute\_config](#input\_compute\_config) | Configuration block for the cluster compute configuration |
object({| `null` | no | +| [compute\_config](#input\_compute\_config) | Configuration block for the cluster compute configuration |
enabled = optional(bool, false)
node_pools = optional(list(string))
node_role_arn = optional(string)
})
object({| `null` | no | | [control\_plane\_subnet\_ids](#input\_control\_plane\_subnet\_ids) | A list of subnet IDs where the EKS cluster control plane (ENIs) will be provisioned. Used for expanding the pool of subnets used by nodes/node groups without replacing the EKS control plane | `list(string)` | `[]` | no | | [create](#input\_create) | Controls if resources should be created (affects nearly all resources) | `bool` | `true` | no | | [create\_cloudwatch\_log\_group](#input\_create\_cloudwatch\_log\_group) | Determines whether a log group is created by this module for the cluster logs. If not, AWS will automatically create one if logging is enabled | `bool` | `true` | no | diff --git a/examples/eks-auto-mode/README.md b/examples/eks-auto-mode/README.md index 204fecd0b4..efc9628509 100644 --- a/examples/eks-auto-mode/README.md +++ b/examples/eks-auto-mode/README.md @@ -39,6 +39,7 @@ Note that this example may create resources which cost money. Run `terraform des |------|--------|---------| | [disabled\_eks](#module\_disabled\_eks) | ../.. | n/a | | [eks](#module\_eks) | ../.. | n/a | +| [eks\_custom\_node\_pools](#module\_eks\_custom\_node\_pools) | ../.. | n/a | | [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 6.0 | ## Resources
enabled = optional(bool, false)
node_pools = optional(list(string), [])
node_role_arn = optional(string)
})