Skip to content

aws-eks: Nodegroup.nodegroupName is not the nodegroup's name #22442

@plumdog

Description

@plumdog

Describe the bug

The result of myNodegroup.nodegroupName is something like mycluster/mynodegroup. This is not the nodegroup's name.

Eg, if I try to pass this to an SDK call to describe the nodegroup, I get:

$ aws eks describe-nodegroup --cluster-name mycluster --nodegroup-name mycluster/mynodegroup

An error occurred (InvalidParameterException) when calling the DescribeNodegroup operation: The nodegroup name parameter contains invalid characters. It should begin with letter or digit and can have any of the following characters: the set of Unicode letters, digits, hyphens and underscores.

Expected Behavior

myNodegroup.nodegroupName to give the name of the nodegroup.

Current Behavior

myNodegroup.nodegroupName is the "physical resource ID", see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html#aws-resource-eks-nodegroup-return-values, because it uses .ref not attrNodegroupName. See eg https://github.com/aws/aws-cdk/blob/v2.33.0/packages/@aws-cdk/aws-eks/lib/managed-nodegroup.ts#L455

Reproduction Steps

Roughly, something like:

const vpc = new ec2.Vpc(this, 'Vpc');
const cluster = new eks.Cluster(this, 'Cluster', {
    clusterName: 'mycluster',
});
const nodegroup = cluster.addNodegroup(...);
new CfnOutput(this, 'NodegroupName', {
    value: nodegroup.nodegroupName,
});

Then call aws eks describe-nodegroup --cluster-name mycluster --nodegroup-name [value from output] and see that it errors.

Possible Solution

Change .nodegroupName to be .attrNodegroupName.

Maybe add .nodegroupPhysicalResourceId as .ref?

Additional Information/Context

This would be a breaking change.

CDK CLI Version

2.33.0

Framework Version

No response

Node.js Version

16

OS

Linux

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-eksRelated to Amazon Elastic Kubernetes ServicebugThis issue is a bug.effort/smallSmall work item – less than a day of effortp2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions