From 56567c6c9188c9d8b475b6e5c2be2f3fb2d26477 Mon Sep 17 00:00:00 2001 From: Ji Xun Yeoh <68215366+jixun999@users.noreply.github.com> Date: Thu, 8 May 2025 18:34:32 +0100 Subject: [PATCH] fix: more robust and cleaner compute_config When not using eks-auto mode, the compute_config for_each condition checks the length of var.cluster_compute_config, which works fine if the variable is not specified. However, if a downstream consumer wants to create a module that toggles eks-auto, then cluster_compute_config must be defined. This change makes the module more robust and ensures it can support both eks-auto and standard EKS configurations. --- main.tf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.tf b/main.tf index c10d79608d..a5a2598ba4 100644 --- a/main.tf +++ b/main.tf @@ -54,12 +54,12 @@ resource "aws_eks_cluster" "this" { } dynamic "compute_config" { - for_each = length(var.cluster_compute_config) > 0 ? [var.cluster_compute_config] : [] + for_each = local.auto_mode_enabled && length(try(var.cluster_compute_config.node_pools, [])) > 0 ? [var.cluster_compute_config] : [] content { - enabled = local.auto_mode_enabled - node_pools = local.auto_mode_enabled ? try(compute_config.value.node_pools, []) : null - node_role_arn = local.auto_mode_enabled && length(try(compute_config.value.node_pools, [])) > 0 ? try(compute_config.value.node_role_arn, aws_iam_role.eks_auto[0].arn, null) : null + enabled = true + node_pools = var.cluster_compute_config.node_pools + node_role_arn = var.cluster_compute_config.node_role_arn } }