From 695030c22509e26997004c57d74db660379a4c3f Mon Sep 17 00:00:00 2001
From: Grzegorz Lisowski <glisowski@worldremit.com>
Date: Thu, 7 May 2020 11:12:50 +0200
Subject: [PATCH] Rebase to master

---
 worker_groups.tf | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/worker_groups.tf b/worker_groups.tf
index cc266e6aaba..d7ae14d0a52 100644
--- a/worker_groups.tf
+++ b/worker_groups.tf
@@ -7,8 +7,8 @@ data "null_data_source" "worker_groups" {
     ## Cannot use cluster_name  to check dependency due to resources cycle:
     ## Error: Cycle: module.eks.module.worker_groups.aws_iam_instance_profile.workers, module.eks.module.worker_groups.output.aws_auth_roles, module.eks.local.configmap_roles, module.eks.kubernetes_config_map.aws_auth, module.eks.data.null_data_source.worker_groups, module.eks.module.worker_groups.var.cluster_name
     ##
-    # cluster_name        = aws_eks_cluster.this[0].name
-    cluster_endpoint    = aws_eks_cluster.this[0].endpoint
+    # cluster_name        = coalescelist(aws_eks_cluster.this[*].name, [""])[0]
+    cluster_endpoint    = coalescelist(aws_eks_cluster.this[*].endpoint, [""])[0]
     cluster_auth_base64 = aws_eks_cluster.this[0].certificate_authority[0].data
 
     # Ensure these resources are created before "unlocking" the data source.
@@ -26,7 +26,7 @@ module "worker_groups" {
 
   create_eks = var.create_eks
 
-  cluster_name        = aws_eks_cluster.this[0].name
+  cluster_name        = coalescelist(aws_eks_cluster.this[*].name, [""])[0]
   cluster_endpoint    = coalescelist(data.null_data_source.worker_groups[*].outputs["cluster_endpoint"], [""])[0]
   cluster_auth_base64 = coalescelist(data.null_data_source.worker_groups[*].outputs["cluster_auth_base64"], [""])[0]