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 "<clusterName>/<nodegroupName>" 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.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-09-22 00:52:41 -04:00
1 parent 9e1e974712
commit 69e371721b
3 files changed
+21 -12

No files matched your search

@@ -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");
}
}
@@ -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<Nodegroup> 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");
@@ -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
1 AWS::AppSync::GraphQLApi GraphQLEndpointArn the private-endpoint ARN of the GraphQL endpoint; Floci serves one public endpoint and has no private-endpoint model
53 AWS::EKS::Cluster ClusterSecurityGroupId not modeled: Floci does not create a cluster security group, so there is no id to publish
54 AWS::EKS::Cluster EncryptionConfigKeyArn not modeled: Floci does not apply envelope encryption, so no KMS key arn is resolved
55 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
56 AWS::IAM::Policy Id not published: Floci uses the policy name for Ref, AWS returns an opaque generated identifier that Floci does not model
57 AWS::IAM::ManagedPolicy AttachmentCount not published: the attachment count is dynamic and Floci does not expose it as a stable Fn::GetAtt value
58 AWS::IAM::ManagedPolicy CreateDate not published: Floci does not surface the policy create date as an Fn::GetAtt value