Commit 55bf451
authored
fix(eks-v2-alpha): prevent IAM role creation when node pools are empty (#33894)
When node pools are disabled (by setting an empty array in nodePools), the IAM role will not be created, preventing deployment failures with the error 'When Compute Config nodeRoleArn is not null or empty, nodePool value(s) must be provided.
### Issue # (if applicable)
Fixes #33771
### Reason for this change
When using EKS Auto Mode with empty node pools (by setting `nodePools: []`), the IAM role was still being created by the L2 construct, causing stack deployment failures. The AWS service returns an error stating that when `nodeRoleArn` is provided, node pool values must also be provided.
### Description of changes
Modified the `computeConfig` section in the `CfnCluster` resource to check if `nodePools` is empty before assigning `nodeRoleArn`. If `nodePools` is empty, `nodeRoleArn` will be set to `undefined` to prevent the unnecessary creation of the IAM role.
The change ensures that when users explicitly disable node pools by providing an empty array, the IAM role won't be created, allowing the cluster to be provisioned successfully.
Added a test case to verify that when node pools are empty:
1. The nodeRoleArn is not included in the CloudFormation template
2. No IAM role resource is created for node pools
### Describe any new or updated permissions being added
No new or updated IAM permissions are being added. This change actually prevents the creation of an IAM role when it's not needed.
### Description of how you validated changes
Added a new test case in `automode.test.ts` that verifies:
- The `nodeRoleArn` property is not included in the CloudFormation template when node pools are empty
- No IAM role resource is created for node pools when they are disabled
The test passes, confirming that our fix works as expected.
### 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 0787840 commit 55bf451
File tree
13 files changed
+5769
-1078
lines changed- packages/@aws-cdk/aws-eks-v2-alpha
- lib
- test
- integ.eks-auto.js.snapshot
13 files changed
+5769
-1078
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
151 | 167 | | |
152 | 168 | | |
153 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1184 | 1184 | | |
1185 | 1185 | | |
1186 | 1186 | | |
| 1187 | + | |
1187 | 1188 | | |
1188 | | - | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
1189 | 1192 | | |
1190 | 1193 | | |
1191 | 1194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
238 | 275 | | |
239 | 276 | | |
240 | 277 | | |
| |||
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