From 69e371721b49d11eaad86c5463650ad4f7df6af2 Mon Sep 17 00:00:00 2001 From: Hector Ventura Date: Mon, 21 Sep 2026 23:52:41 -0500 Subject: [PATCH] fix(cloudformation): make EKS Nodegroup Ref the composite cluster/nodegroup id (#4136) AWS::EKS::Nodegroup Ref returned the bare nodegroup name, but AWS returns the composite "/" id. Publish that as the physical id (Ref) and the readOnly Id attribute, and drive delete from the stored ClusterName and NodegroupName attributes rather than parsing the physical id. Removes the EKS Nodegroup Id gap row now that the attribute is set. --- .../provisioners/EksCfnProvisioner.java | 20 ++++++++++++------- .../provisioners/EksCfnProvisionerTest.java | 12 +++++++---- .../cloudformation/getatt-attribute-gaps.tsv | 1 - 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/EksCfnProvisioner.java b/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/EksCfnProvisioner.java index 6dd99bf445..3ee846a0f8 100644 --- a/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/EksCfnProvisioner.java +++ b/src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/EksCfnProvisioner.java @@ -82,9 +82,12 @@ public class EksCfnProvisioner implements CfnResourceProvisioner { request.setSubnets(ctx.resolveStringList(props, "Subnets")); Nodegroup nodegroup = eksService.createNodeGroup(clusterName, request); - r.setPhysicalId(nodegroup.getNodegroupName()); - // ClusterName is stored so delete() can find the cluster, and NodegroupName mirrors the - // physical id; Arn is the schema's read-only attribute. + // Ref (and the readOnly Id) is the composite the registry primary identifier declares, + // clusterName/nodegroupName, matching AWS. The plain names stay as their own attributes: + // ClusterName and NodegroupName back delete() and Fn::GetAtt. + String id = nodegroup.getClusterName() + "/" + nodegroup.getNodegroupName(); + r.setPhysicalId(id); + r.getAttributes().put("Id", id); r.getAttributes().put("ClusterName", nodegroup.getClusterName()); r.getAttributes().put("NodegroupName", nodegroup.getNodegroupName()); if (nodegroup.getNodegroupArn() != null) { @@ -98,12 +101,15 @@ public class EksCfnProvisioner implements CfnResourceProvisioner { case CLUSTER -> CfnDeletes.safeDelete("EKS cluster", resource.getPhysicalId(), () -> eksService.deleteCluster(resource.getPhysicalId()), "ResourceNotFoundException"); case NODEGROUP -> { - // Deleting a nodegroup needs the cluster name (a create-time attribute) as well as - // the nodegroup name (the physical id), which the id-only delete path cannot supply. + // Deleting a nodegroup needs the cluster name and the nodegroup name, both stored as + // create-time attributes; the physical id is now the composite clusterName/nodegroupName, + // so it cannot be passed as the nodegroup name. String clusterName = resource.getAttributes().get("ClusterName"); - if (clusterName != null && !clusterName.isBlank()) { + String nodegroupName = resource.getAttributes().get("NodegroupName"); + if (clusterName != null && !clusterName.isBlank() + && nodegroupName != null && !nodegroupName.isBlank()) { CfnDeletes.safeDelete("EKS nodegroup", resource.getPhysicalId(), - () -> eksService.deleteNodeGroup(clusterName, resource.getPhysicalId()), + () -> eksService.deleteNodeGroup(clusterName, nodegroupName), "ResourceNotFoundException"); } } diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/EksCfnProvisionerTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/EksCfnProvisionerTest.java index aef6481aa2..28cac3c951 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/EksCfnProvisionerTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/EksCfnProvisionerTest.java @@ -85,7 +85,7 @@ class EksCfnProvisionerTest { } @Test - void nodegroupRefIsItsNameAndItStoresTheClusterNameForDelete() throws Exception { + void nodegroupRefIsTheCompositeIdAndItStoresNamesForDelete() throws Exception { Nodegroup created = new Nodegroup(); created.setNodegroupName("workers"); created.setClusterName("prod"); @@ -98,8 +98,11 @@ class EksCfnProvisionerTest { "NodeRole": "arn:aws:iam::000000000000:role/nodes", "Subnets": ["subnet-1", "subnet-2"]} """), ctx()); - assertEquals("workers", r.getPhysicalId()); + // Ref and Id are the composite clusterName/nodegroupName, matching AWS. + assertEquals("prod/workers", r.getPhysicalId()); + assertEquals("prod/workers", r.getAttributes().get("Id")); assertEquals("prod", r.getAttributes().get("ClusterName")); + assertEquals("workers", r.getAttributes().get("NodegroupName")); assertEquals("arn:aws:eks:us-east-1:000000000000:nodegroup/prod/workers/uuid", r.getAttributes().get("Arn")); ArgumentCaptor request = ArgumentCaptor.forClass(Nodegroup.class); @@ -118,10 +121,11 @@ class EksCfnProvisionerTest { } @Test - void deleteRemovesTheNodegroupUsingTheStoredClusterName() { + void deleteRemovesTheNodegroupUsingTheStoredNames() { StackResource r = resource("AWS::EKS::Nodegroup", "Workers"); - r.setPhysicalId("workers"); + r.setPhysicalId("prod/workers"); r.getAttributes().put("ClusterName", "prod"); + r.getAttributes().put("NodegroupName", "workers"); provisioner.delete(r, "us-east-1"); diff --git a/src/test/resources/cloudformation/getatt-attribute-gaps.tsv b/src/test/resources/cloudformation/getatt-attribute-gaps.tsv index 05261cedde..8cb937051f 100644 --- a/src/test/resources/cloudformation/getatt-attribute-gaps.tsv +++ b/src/test/resources/cloudformation/getatt-attribute-gaps.tsv @@ -53,7 +53,6 @@ AWS::SecretsManager::Secret Id Fn::GetAtt Id on a secret is its ARN, which the p AWS::EKS::Cluster ClusterSecurityGroupId not modeled: Floci does not create a cluster security group, so there is no id to publish AWS::EKS::Cluster EncryptionConfigKeyArn not modeled: Floci does not apply envelope encryption, so no KMS key arn is resolved AWS::EKS::Cluster Id not modeled: Floci identifies a cluster by its Name (the primary identifier and Ref), not a separate Id -AWS::EKS::Nodegroup Id not published: Floci identifies a nodegroup by its name within the cluster, which is the Ref, not the composite Id AWS::IAM::Policy Id not published: Floci uses the policy name for Ref, AWS returns an opaque generated identifier that Floci does not model AWS::IAM::ManagedPolicy AttachmentCount not published: the attachment count is dynamic and Floci does not expose it as a stable Fn::GetAtt value AWS::IAM::ManagedPolicy CreateDate not published: Floci does not surface the policy create date as an Fn::GetAtt value