From c3d6c5ba3019c5ec1d9561bb4e0612a082aeb873 Mon Sep 17 00:00:00 2001 From: Jian Zeng Date: Fri, 7 Jan 2022 00:37:46 +0800 Subject: [PATCH] fix: Not to iterate over remote_access object in dynamic block --- examples/eks_managed_node_group/main.tf | 4 ++++ modules/eks-managed-node-group/main.tf | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/eks_managed_node_group/main.tf b/examples/eks_managed_node_group/main.tf index 68d3868a56..b45505a198 100644 --- a/examples/eks_managed_node_group/main.tf +++ b/examples/eks_managed_node_group/main.tf @@ -173,6 +173,10 @@ module "eks" { } ] + remote_access = { + ec2_ssh_key = "my-ssh-key" + } + update_config = { max_unavailable_percentage = 50 # or set `max_unavailable` } diff --git a/modules/eks-managed-node-group/main.tf b/modules/eks-managed-node-group/main.tf index e70e93a239..3188a8d910 100644 --- a/modules/eks-managed-node-group/main.tf +++ b/modules/eks-managed-node-group/main.tf @@ -295,10 +295,10 @@ resource "aws_eks_node_group" "this" { } dynamic "remote_access" { - for_each = var.remote_access + for_each = length(var.remote_access) > 0 ? [var.remote_access] : [] content { - ec2_ssh_key = lookup(remote_access.value, "ec2_ssh_key", null) - source_security_group_ids = lookup(remote_access.value, "source_security_group_ids", []) + ec2_ssh_key = try(remote_access.value.ec2_ssh_key, null) + source_security_group_ids = try(remote_access.value.source_security_group_ids, []) } }