Skip to content

Commit e77ce26

Browse files
authored
fix(eks): missing support for "InstanceTypes" attribute assignment for AL2023 AMIs (#29505)
### Issue # (if applicable) Closes #29546 ### Reason for this change After #29335, `@aws-eks` should receive AL2023 support, despites the [GPU types are not yet supported](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html#cfn-eks-nodegroup-amitype) it should at least allow user to customize instance type. However, missing support for `NodegroupAmiType[]` causing validation error emit, so that user can only create [default instance types](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html#cfn-eks-nodegroup-instancetypes) ( `t3.medium` or `t4g.medium` ). ``` $ cat ./lib/cluster.ts ... cluster.addNodegroupCapacity("mng-al2023", { amiType: eks.NodegroupAmiType.AL2023_X86_64_STANDARD, instanceTypes: [new ec2.InstanceType("t3.medium")], ... }); ... ``` ``` $ npx cdk version 2.133.0 (build dcc1e75) ``` ``` $ npx cdk synth ... ^ Error: The specified AMI does not match the instance types architecture, either specify one of AL2_X86_64, BOTTLEROCKET_X86_64, WINDOWS_CORE_2019_X86_64, WINDOWS_CORE_2022_X86_64, WINDOWS_FULL_2019_X86_64, WINDOWS_FULL_2022_X86_64 or don't specify any at new Nodegroup (.../node_modules/aws-cdk-lib/aws-eks/lib/managed-nodegroup.js:1:3921) at Cluster.addNodegroupCapacity (.../node_modules/aws-cdk-lib/aws-eks/lib/cluster.js:1:19807) at EksCluster.createManagedNodeGroups (.../lib/cluster.ts:85:13) at new EksCluster (.../lib/cluster.ts:30:10) at Object.<anonymous> (.../bin/eks-basic.ts:10:1) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Module.m._compile (.../node_modules/ts-node/src/index.ts:1618:23) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Object.require.extensions.<computed> [as .ts] (.../node_modules/ts-node/src/index.ts:1621:12) at Module.load (node:internal/modules/cjs/loader:1207:32) Subprocess exited with error 1 ``` ### Description of changes Add `eks.NodegroupAmiType.AL2023_X86_64_STANDARD` and `eks.NodegroupAmiType.AL2023_ARM_64_STANDARD` support for node group module. ### Description of how you validated changes ``` $ npx jest aws-eks/test/cluster.test.ts PASS aws-eks/test/cluster.test.ts (37.298 s) ... =============================== Coverage summary =============================== Statements : 48.86% ( 10077/20621 ) Branches : 27.88% ( 2388/8565 ) Functions : 33.03% ( 1509/4568 ) Lines : 49.71% ( 9905/19923 ) ================================================================================ Jest: "global" coverage threshold for statements (55%) not met: 48.86% Jest: "global" coverage threshold for branches (35%) not met: 27.88% Test Suites: 1 passed, 1 total Tests: 119 passed, 119 total Snapshots: 0 total Time: 41.064 s ``` ``` $ npx jest aws-eks/test/nodegroup.test.ts RUNS aws-eks/test/nodegroup.test.ts ... =============================== Coverage summary =============================== Statements : 43.94% ( 9062/20621 ) Branches : 22.08% ( 1892/8565 ) Functions : 27.16% ( 1241/4568 ) Lines : 44.8% ( 8927/19923 ) ================================================================================ Jest: "global" coverage threshold for statements (55%) not met: 43.94% Jest: "global" coverage threshold for branches (35%) not met: 22.08% Test Suites: 1 passed, 1 total Tests: 59 passed, 59 total Snapshots: 0 total Time: 23.334 s ``` ### Checklist - [X] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent f60e6e9 commit e77ce26

31 files changed

+7433
-17
lines changed

packages/@aws-cdk-testing/framework-integ/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"dependencies": {
4141
"@aws-cdk/integ-tests-alpha": "0.0.0",
4242
"@aws-cdk/lambda-layer-kubectl-v24": "^2.0.242",
43+
"@aws-cdk/lambda-layer-kubectl-v29": "^2.0.0",
4344
"aws-cdk-lib": "0.0.0",
4445
"aws-sdk": "^2.1583.0",
4546
"aws-sdk-mock": "5.6.0",
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
import * as lambda from 'aws-cdk-lib/aws-lambda';
22
import { KubectlV24Layer } from '@aws-cdk/lambda-layer-kubectl-v24';
3+
import { KubectlV29Layer } from '@aws-cdk/lambda-layer-kubectl-v29';
34
import { Construct } from 'constructs';
45
import * as eks from 'aws-cdk-lib/aws-eks';
56

6-
export function getClusterVersionConfig(scope: Construct) {
7+
const versionMap: { [key: string]: any } = {
8+
1.24: KubectlV24Layer,
9+
1.29: KubectlV29Layer,
10+
};
11+
12+
export function getClusterVersionConfig(scope: Construct, version?: eks.KubernetesVersion) {
13+
const _version = version ?? eks.KubernetesVersion.V1_24;
714
return {
8-
version: eks.KubernetesVersion.V1_24,
15+
version: _version,
916
// Crazy type-casting is required because KubectlLayer peer depends on
1017
// types from aws-cdk-lib, but we run integration tests in the @aws-cdk/
1118
// v1-style directory, not in the aws-cdk-lib v2-style directory.
12-
kubectlLayer: new KubectlV24Layer(scope, 'KubectlLayer') as unknown as lambda.ILayerVersion,
19+
// kubectlLayer: new KubectlV24Layer(scope, 'KubectlLayer') as unknown as lambda.ILayerVersion,
20+
kubectlLayer: new versionMap[_version.version](scope, 'KubectlLayer') as unknown as lambda.ILayerVersion,
1321
};
1422
};

packages/@aws-cdk-testing/framework-integ/test/aws-eks/test/integ.eks-al2023-nodegroup.js.snapshot/asset.1471fa6f2876749a13de79989efc6651c9768d3173ef5904947e87504f8d7069/apply/__init__.py

+95
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-eks/test/integ.eks-al2023-nodegroup.js.snapshot/asset.1471fa6f2876749a13de79989efc6651c9768d3173ef5904947e87504f8d7069/get/__init__.py

+88
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)