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

chore(eks): remove propertyOverride for nodegroup launchTemplate #14499

Merged
merged 2 commits into from
May 3, 2021

Conversation

kirintwn
Copy link
Contributor

@kirintwn kirintwn commented May 3, 2021

Previously we use addPropertyOverride() when specifying launch template for a nodegroup:

// TODO: update this when the L1 resource spec is updated.
resource.addPropertyOverride('LaunchTemplate', {
Id: props.launchTemplateSpec.id,
Version: props.launchTemplateSpec.version,
});

This is now available on new cfn spec that cdk uses. So we can safely migrate to cfn props instead of calling addPropertyOverride().

The unit test should still covered the changes:

'create nodegroup correctly with launch template'(test: Test) {
// GIVEN
const { stack, vpc } = testFixture();
// WHEN
const cluster = new eks.Cluster(stack, 'Cluster', {
vpc,
defaultCapacity: 0,
version: CLUSTER_VERSION,
});
const userData = ec2.UserData.forLinux();
userData.addCommands(
'set -o xtrace',
`/etc/eks/bootstrap.sh ${cluster.clusterName}`,
);
const lt = new ec2.CfnLaunchTemplate(stack, 'LaunchTemplate', {
launchTemplateData: {
imageId: new eks.EksOptimizedImage().getImage(stack).imageId,
instanceType: new ec2.InstanceType('t3.small').toString(),
userData: cdk.Fn.base64(userData.render()),
},
});
cluster.addNodegroupCapacity('ng-lt', {
launchTemplateSpec: {
id: lt.ref,
version: lt.attrDefaultVersionNumber,
},
});
// THEN
expect(stack).to(haveResourceLike('AWS::EKS::Nodegroup', {
LaunchTemplate: {
Id: {
Ref: 'LaunchTemplate',
},
Version: {
'Fn::GetAtt': [
'LaunchTemplate',
'DefaultVersionNumber',
],
},
},
},
));
test.done();
},
'throws when both diskSize and launch template specified'(test: Test) {
// GIVEN
const { stack, vpc } = testFixture();
// WHEN
const cluster = new eks.Cluster(stack, 'Cluster', {
vpc,
defaultCapacity: 0,
version: CLUSTER_VERSION,
});
const userData = ec2.UserData.forLinux();
userData.addCommands(
'set -o xtrace',
`/etc/eks/bootstrap.sh ${cluster.clusterName}`,
);
const lt = new ec2.CfnLaunchTemplate(stack, 'LaunchTemplate', {
launchTemplateData: {
imageId: new eks.EksOptimizedImage().getImage(stack).imageId,
instanceType: new ec2.InstanceType('t3.small').toString(),
userData: cdk.Fn.base64(userData.render()),
},
});
// THEN
test.throws(() =>
cluster.addNodegroupCapacity('ng-lt', {
diskSize: 100,
launchTemplateSpec: {
id: lt.ref,
version: lt.attrDefaultVersionNumber,
},
}), /diskSize must be specified within the launch template/);
test.done();
},


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented May 3, 2021

@github-actions github-actions bot added the @aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service label May 3, 2021
@kirintwn kirintwn requested a review from iliapolo May 3, 2021 16:18
@mergify
Copy link
Contributor

mergify bot commented May 3, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 7cfc0cd
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 9570747 into aws:master May 3, 2021
@mergify
Copy link
Contributor

mergify bot commented May 3, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

john-tipper pushed a commit to john-tipper/aws-cdk that referenced this pull request May 10, 2021
…#14499)

Previously we use `addPropertyOverride()` when specifying launch template for a nodegroup:
https://github.com/aws/aws-cdk/blob/e11d5378c33bea609ed09c998b305fdfd28999a9/packages/%40aws-cdk/aws-eks/lib/managed-nodegroup.ts#L359-L363

This is now available on new cfn spec that cdk uses. So we can safely migrate to cfn props instead of calling `addPropertyOverride()`.

The unit test should still covered the changes:
https://github.com/aws/aws-cdk/blob/e11d5378c33bea609ed09c998b305fdfd28999a9/packages/%40aws-cdk/aws-eks/test/test.nodegroup.ts#L565-L643

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this pull request Aug 26, 2021
…#14499)

Previously we use `addPropertyOverride()` when specifying launch template for a nodegroup:
https://github.com/aws/aws-cdk/blob/e11d5378c33bea609ed09c998b305fdfd28999a9/packages/%40aws-cdk/aws-eks/lib/managed-nodegroup.ts#L359-L363

This is now available on new cfn spec that cdk uses. So we can safely migrate to cfn props instead of calling `addPropertyOverride()`.

The unit test should still covered the changes:
https://github.com/aws/aws-cdk/blob/e11d5378c33bea609ed09c998b305fdfd28999a9/packages/%40aws-cdk/aws-eks/test/test.nodegroup.ts#L565-L643

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants