Skip to content

Commit ecc540e

Browse files
authored
Merge branch 'main' into scheduler-alpha-module-graduation
2 parents b295311 + 9c47f1b commit ecc540e

15 files changed

+5771
-1080
lines changed

.github/workflows/analytics-metadata-updater.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
update-analytics-metadata:
10-
if: github.repository == 'aws/aws-cdk'
10+
if: github.repository == 'aws/aws-cdk' && github.actor == 'aws-cdk-automation'
1111
runs-on: ubuntu-latest
1212
permissions:
1313
contents: write

.github/workflows/lambda-runtime-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
update-lambda-tests:
9-
if: github.repository == 'aws/aws-cdk'
9+
if: github.repository == 'aws/aws-cdk' && github.actor == 'aws-cdk-automation'
1010
runs-on: ubuntu-latest
1111
permissions:
1212
contents: write

packages/@aws-cdk/aws-eks-v2-alpha/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,22 @@ const cluster = new eks.Cluster(this, 'EksAutoCluster', {
148148

149149
For more information, see [Create a Node Pool for EKS Auto Mode](https://docs.aws.amazon.com/eks/latest/userguide/create-node-pool.html).
150150

151+
### Disabling Default Node Pools
152+
153+
You can disable the default node pools entirely by setting an empty array for `nodePools`. This is useful when you want to use Auto Mode features but manage your compute resources separately:
154+
155+
```ts
156+
const cluster = new eks.Cluster(this, 'EksAutoCluster', {
157+
version: eks.KubernetesVersion.V1_32,
158+
defaultCapacityType: eks.DefaultCapacityType.AUTOMODE,
159+
compute: {
160+
nodePools: [], // Disable default node pools
161+
},
162+
});
163+
```
164+
165+
When node pools are disabled this way, no IAM role will be created for the node pools, preventing deployment failures that would otherwise occur when a role is created without any node pools.
166+
151167
### Node Groups as the default capacity type
152168

153169
If you prefer to manage your own node groups instead of using Auto Mode, you can use the traditional node group approach by specifying `defaultCapacityType` as `NODEGROUP`:

packages/@aws-cdk/aws-eks-v2-alpha/lib/cluster.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,8 +1184,11 @@ export class Cluster extends ClusterBase {
11841184
enabled: autoModeEnabled,
11851185
// If the computeConfig enabled flag is set to false when creating a cluster with Auto Mode,
11861186
// the request must not include values for the nodeRoleArn or nodePools fields.
1187+
// Also, if nodePools is empty, nodeRoleArn should not be included to prevent deployment failures
11871188
nodePools: !autoModeEnabled ? undefined : props.compute?.nodePools ?? ['system', 'general-purpose'],
1188-
nodeRoleArn: !autoModeEnabled ? undefined : props.compute?.nodeRole?.roleArn ?? this.addNodePoolRole(`${id}nodePoolRole`).roleArn,
1189+
nodeRoleArn: !autoModeEnabled || (props.compute?.nodePools && props.compute.nodePools.length === 0) ?
1190+
undefined :
1191+
props.compute?.nodeRole?.roleArn ?? this.addNodePoolRole(`${id}nodePoolRole`).roleArn,
11891192
},
11901193
storageConfig: {
11911194
blockStorage: {

packages/@aws-cdk/aws-eks-v2-alpha/test/automode.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,43 @@ describe('eks auto mode', () => {
235235
},
236236
});
237237
});
238+
239+
test('does not include nodeRoleArn when nodePools is empty', () => {
240+
const { stack } = testFixtureNoVpc();
241+
242+
new eks.Cluster(stack, 'Cluster', {
243+
version: CLUSTER_VERSION,
244+
defaultCapacityType: eks.DefaultCapacityType.AUTOMODE,
245+
compute: {
246+
nodePools: [],
247+
},
248+
});
249+
250+
// Verify that nodeRoleArn is not included in the CloudFormation template
251+
Template.fromStack(stack).hasResourceProperties('AWS::EKS::Cluster', {
252+
ComputeConfig: {
253+
Enabled: true,
254+
NodePools: [],
255+
},
256+
});
257+
258+
// Verify that nodeRoleArn is not present in the ComputeConfig
259+
const template = Template.fromStack(stack);
260+
const cluster = template.findResources('AWS::EKS::Cluster');
261+
const clusterLogicalId = Object.keys(cluster)[0];
262+
const computeConfig = cluster[clusterLogicalId].Properties.ComputeConfig;
263+
264+
expect(computeConfig).not.toHaveProperty('NodeRoleArn');
265+
266+
// Verify that no IAM role resource is created for node pools
267+
// The role would typically have a logical ID like 'ClusterClusternodePoolRole...'
268+
const iamRoles = template.findResources('AWS::IAM::Role');
269+
const nodePoolRoleKeys = Object.keys(iamRoles).filter(key =>
270+
key.includes('nodePoolRole'),
271+
);
272+
273+
expect(nodePoolRoleKeys.length).toBe(0);
274+
});
238275
});
239276

240277
describe('network configuration', () => {

packages/@aws-cdk/aws-eks-v2-alpha/test/integ.eks-auto.js.snapshot/eks-auto-mode-empty-nodepools-stack.assets.json

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)