aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.33k stars 3.76k forks source link

aws-eks: Support `CUSTOM` AMI type on Nodegroups #30641

Open Artemigos opened 4 days ago

Artemigos commented 4 days ago

Describe the feature

CloudFormation supports passing CUSTOM as value for AmiType: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html#cfn-eks-nodegroup-amitype

This is not available in CDK, making the use of custom AMIs impossible.

Use Case

When building custom AMIs for a cluster (e.g. based on the EKS optimized images) you should be able to use them.

Proposed Solution

Rough idea:

It looks like this should already be enough, but I didn't actually attempt doing this.

Other Information

I tried forcing the issue by bypassing TypeScript checks: amiType: ('CUSTOM' as any) - internal check rejected it. After investigating a little - the Nodegroup constructor tries to do the right thing and validates the value, but completely ignores the existence of CUSTOM in CloudFormation.

Acknowledgements

CDK version used

2.133.0

Environment details (OS name and version, etc.)

Ubuntu 22.04.4 LTS

pahud commented 4 days ago

@Artemigos Yes we should support that.

  1. when CUSTOM is provided, a launch template has to be provided as well.
  2. we probably should add CUSTOM to possibleAmiTypes here:

https://github.com/aws/aws-cdk/blob/3b95777ee5dae32fd41481d81922d07c804a2c6b/packages/aws-cdk-lib/aws-eks/lib/managed-nodegroup.ts#L429

Feel free to submit a PR for it. Thank you.