From ac8de1da542d92523b13ebc12477fe56b9da5007 Mon Sep 17 00:00:00 2001 From: Zee Date: Thu, 23 Feb 2023 14:47:22 +0100 Subject: [PATCH] feat: allow users to override Name tag in autoscaling group --- nodejs/eks/nodegroup.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/nodejs/eks/nodegroup.ts b/nodejs/eks/nodegroup.ts index b312c3537..4e2959a02 100644 --- a/nodejs/eks/nodegroup.ts +++ b/nodejs/eks/nodegroup.ts @@ -843,14 +843,17 @@ ${customUserData} } const autoScalingGroupTags: InputTags = pulumi .all([eksCluster.name, args.autoScalingGroupTags]) - .apply( - ([clusterName, asgTags]) => - { - Name: `${clusterName}-worker`, - [`kubernetes.io/cluster/${clusterName}`]: "owned", - ...asgTags, - }, - ); + .apply(([clusterName, asgTags]): aws.Tags => { + if (!asgTags) { asgTags = {} } + // The kubernetes.io/cluster/ tag is required to be set to "owned" + // Users should not be able to override this tag. + asgTags[`kubernetes.io/cluster/${clusterName}`] = "owned"; + // Only set the Name tag if it's not already set to allow users to override it. + if (!asgTags["Name"]) { + asgTags["Name"] = `${clusterName}-worker`; + } + return asgTags; + }); const cfnTemplateBody = pulumi .all([