Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(aws-eks): nodegroupName attribute correctly assigned #22910

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-eks/lib/managed-nodegroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export class Nodegroup extends Resource implements INodegroup {
resource: 'nodegroup',
resourceName: this.physicalName,
});
this.nodegroupName = this.getResourceNameAttribute(resource.ref);
this.nodegroupName = resource.getAtt('NodegroupName').toString();
}
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@
}
}
},
"56b85a7bb756e34ab12549549eb40d34151db41531599e8f2be6c04e8ae66057": {
"2df5a59d801a1efa337d7f2787d401cc48d736faa94d1f42eccad2d88f3ce2e3": {
"source": {
"path": "asset.56b85a7bb756e34ab12549549eb40d34151db41531599e8f2be6c04e8ae66057",
"path": "asset.2df5a59d801a1efa337d7f2787d401cc48d736faa94d1f42eccad2d88f3ce2e3",
"packaging": "zip"
},
"destinations": {
"current_account-us-east-1": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1",
"objectKey": "56b85a7bb756e34ab12549549eb40d34151db41531599e8f2be6c04e8ae66057.zip",
"objectKey": "2df5a59d801a1efa337d7f2787d401cc48d736faa94d1f42eccad2d88f3ce2e3.zip",
"region": "us-east-1",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-us-east-1"
}
Expand Down Expand Up @@ -155,15 +155,15 @@
}
}
},
"77456616273f830b88c22b926c7c1deddf05464cd14e12c811728546bedddc40": {
"cf46a1b29f63370884ffaf142bdf0332656f174bd4f0debba574c6eb409c948a": {
"source": {
"path": "aws-cdk-eks-cluster-test.template.json",
"packaging": "file"
},
"destinations": {
"current_account-us-east-1": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1",
"objectKey": "77456616273f830b88c22b926c7c1deddf05464cd14e12c811728546bedddc40.json",
"objectKey": "cf46a1b29f63370884ffaf142bdf0332656f174bd4f0debba574c6eb409c948a.json",
"region": "us-east-1",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-us-east-1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2608,6 +2608,7 @@
"InstanceTypes": [
"t3.small"
],
"NodegroupName": "extra-ng",
"ScalingConfig": {
"DesiredSize": 1,
"MaxSize": 1,
Expand Down Expand Up @@ -3238,7 +3239,7 @@
"OpenIdConnectIssuerUrl"
]
},
"CodeHash": "56b85a7bb756e34ab12549549eb40d34151db41531599e8f2be6c04e8ae66057"
"CodeHash": "2df5a59d801a1efa337d7f2787d401cc48d736faa94d1f42eccad2d88f3ce2e3"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
Expand Down Expand Up @@ -3551,7 +3552,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1"
},
"S3Key": "56b85a7bb756e34ab12549549eb40d34151db41531599e8f2be6c04e8ae66057.zip"
"S3Key": "2df5a59d801a1efa337d7f2787d401cc48d736faa94d1f42eccad2d88f3ce2e3.zip"
},
"Timeout": 900,
"MemorySize": 128,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-us-east-1",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-us-east-1",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1/77456616273f830b88c22b926c7c1deddf05464cd14e12c811728546bedddc40.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-us-east-1/cf46a1b29f63370884ffaf142bdf0332656f174bd4f0debba574c6eb409c948a.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down Expand Up @@ -662,7 +662,10 @@
"/aws-cdk-eks-cluster-test/Cluster/Nodegroupextra-ng/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "ClusterNodegroupextrangF9406A09"
"data": "ClusterNodegroupextrangF9406A09",
"trace": [
"!!DESTRUCTIVE_CHANGES: WILL_REPLACE"
]
}
],
"/aws-cdk-eks-cluster-test/Cluster/Nodegroupextra-ng-spot/NodeGroupRole/Resource": [
Expand Down
185 changes: 185 additions & 0 deletions packages/@aws-cdk/aws-eks/test/integ.eks-cluster.js.snapshot/tree.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-eks/test/integ.eks-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ class EksClusterStack extends Stack {
minSize: 1,
// reusing the default capacity nodegroup instance role when available
nodeRole: this.cluster.defaultCapacity ? this.cluster.defaultCapacity.role : undefined,
// custom nodegropuName
nodegroupName: 'extra-ng',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add an assert to this test that checks that this is correctly set.

});
}
private assertNodeGroupSpot() {
Expand Down
29 changes: 28 additions & 1 deletion packages/@aws-cdk/aws-eks/test/nodegroup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,34 @@ describe('node group', () => {
Outputs: {
NodegroupName: {
Value: {
'Fn::ImportValue': 'Stack:ExportsOutputRefNodegroup62B4B2C1EF8AB7C1',
'Fn::ImportValue': 'Stack:ExportsOutputFnGetAttNodegroup62B4B2C1NodegroupName2D50892D',
},
},
},
});
});

test('nodegroupName is set correctly', () => {
// GIVEN
const { stack, vpc } = testFixture();
const cluster = new eks.Cluster(stack, 'Cluster', {
vpc,
defaultCapacity: 0,
version: CLUSTER_VERSION,
});

// WHEN
const ng = new eks.Nodegroup(stack, 'Nodegroup', { cluster, nodegroupName: 'mock-name' });
new cdk.CfnOutput(stack, 'NodegroupName', { value: ng.nodegroupName });
// THEN
Template.fromStack(stack).templateMatches({
Outputs: {
NodegroupName: {
Value: {
'Fn::GetAtt': [
'Nodegroup62B4B2C1',
'NodegroupName',
],
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions packages/aws-cdk-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@
"./aws-opensearchservice": "./aws-opensearchservice/index.js",
"./aws-opsworks": "./aws-opsworks/index.js",
"./aws-opsworkscm": "./aws-opsworkscm/index.js",
"./aws-organizations": "./aws-organizations/index.js",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file shouldn't be included in this commit.

"./aws-panorama": "./aws-panorama/index.js",
"./aws-personalize": "./aws-personalize/index.js",
"./aws-pinpoint": "./aws-pinpoint/index.js",
Expand All @@ -582,6 +583,7 @@
"./aws-refactorspaces": "./aws-refactorspaces/index.js",
"./aws-rekognition": "./aws-rekognition/index.js",
"./aws-resiliencehub": "./aws-resiliencehub/index.js",
"./aws-resourceexplorer2": "./aws-resourceexplorer2/index.js",
"./aws-resourcegroups": "./aws-resourcegroups/index.js",
"./aws-robomaker": "./aws-robomaker/index.js",
"./aws-rolesanywhere": "./aws-rolesanywhere/index.js",
Expand All @@ -600,6 +602,7 @@
"./aws-s3outposts": "./aws-s3outposts/index.js",
"./aws-sagemaker": "./aws-sagemaker/index.js",
"./aws-sam": "./aws-sam/index.js",
"./aws-scheduler": "./aws-scheduler/index.js",
"./aws-sdb": "./aws-sdb/index.js",
"./aws-secretsmanager": "./aws-secretsmanager/index.js",
"./aws-securityhub": "./aws-securityhub/index.js",
Expand Down