feat(batch): add AL2023 image types and default to AL2023 (under feature flag)#37539
feat(batch): add AL2023 image types and default to AL2023 (under feature flag)#37539aws-joelherd wants to merge 1 commit intoaws:mainfrom
Conversation
…ure flag) Add missing enum values for AWS Batch Ec2Configuration: - EcsMachineImageType.ECS_AL2023_NVIDIA - EksMachineImageType.EKS_AL2023 - EksMachineImageType.EKS_AL2023_NVIDIA Introduce feature flag `@aws-cdk/aws-batch:defaultToAL2023` that switches the default imageType from AL2 to AL2023 for both ECS and EKS compute environments. Amazon Linux 2 has reached EOL for EKS (Nov 2025) and reaches EOL for ECS in June 2026. For EKS compute environments with a launch template, automatically set `userdataType` to `EKS_NODEADM` when an AL2023 image type is resolved, as required by the AWS Batch API to ensure nodes join the cluster. Update A1 instance validation to also reject ECS_AL2023_NVIDIA and to correctly resolve the feature-flag-defaulted imageType. Closes aws#35839, closes aws#37205
There was a problem hiding this comment.
The pull request linter fails with the following errors:
❌ Features must contain a change to an integration test file and the resulting snapshot.
If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.
✅ A exemption request has been requested. Please wait for a maintainer's review.
Exemption Request This change adds new enum values and a feature flag that only affects the default |
| * - ECS_AL2 compatible AMI ids for non-GPU instances, ECS_AL2_NVIDIA compatible AMI ids for GPU instances. | ||
| * If the '@aws-cdk/aws-batch:defaultToAL2023' feature flag is set, ECS_AL2023 will be used instead of ECS_AL2. |
There was a problem hiding this comment.
Note: the '@aws-cdk/aws-batch:defaultToAL2023' feature flag makes the default change backwards compatible for existing customers.
| const resolved = image.imageType ?? ( | ||
| FeatureFlags.of(this).isEnabled(cxapi.BATCH_DEFAULT_AL2023) | ||
| ? EcsMachineImageType.ECS_AL2023 | ||
| : EcsMachineImageType.ECS_AL2 | ||
| ); | ||
| return [EcsMachineImageType.ECS_AL2023, EcsMachineImageType.ECS_AL2023_NVIDIA].includes(resolved); |
There was a problem hiding this comment.
Note: Expands the validation error for A1 instance types and AL2023 NVIDIA GPU images as well.
| userdataType: this.images?.some(image => { | ||
| const resolved = image.imageType ?? ( | ||
| FeatureFlags.of(this).isEnabled(cxapi.BATCH_DEFAULT_AL2023) | ||
| ? EksMachineImageType.EKS_AL2023 | ||
| : EksMachineImageType.EKS_AL2 | ||
| ); | ||
| return [EksMachineImageType.EKS_AL2023, EksMachineImageType.EKS_AL2023_NVIDIA].includes(resolved); | ||
| }) ? 'EKS_NODEADM' : undefined, | ||
| } : undefined, |
There was a problem hiding this comment.
Note: AL2->AL2023 UserdataType is publicly documented here:
| const app = new App({ | ||
| context: { [cxapi.BATCH_DEFAULT_AL2023]: true }, | ||
| }); |
There was a problem hiding this comment.
Note: Unit tests for ECS CEs when feature flag is enabled.
| const app = new App({ | ||
| context: { [cxapi.BATCH_DEFAULT_AL2023]: true }, | ||
| }); |
There was a problem hiding this comment.
Note: Unit tests for EKS CEs when feature flag is enabled.
| }); | ||
| }); | ||
|
|
||
| test('sets userdataType to EKS_NODEADM when launch template is used with EKS_AL2023', () => { |
There was a problem hiding this comment.
Note: Unit tests for EKS CEs and their Userdata Type based on ImageType.
| const app = new App({ | ||
| context: { [cxapi.BATCH_DEFAULT_AL2023]: true }, | ||
| }); |
There was a problem hiding this comment.
Note: Unit tests for EKS CEs and their Userdata Type based on ImageType, with feature flag enabled.
|
|
||
| ////////////////////////////////////////////////////////////////////// | ||
| [BATCH_DEFAULT_AL2023]: { | ||
| type: FlagType.ApiDefault, |
There was a problem hiding this comment.
Note: This is the default behavior of service API's since January 2026.
Add missing enum values for AWS Batch Ec2Configuration:
Introduce feature flag
@aws-cdk/aws-batch:defaultToAL2023that switches the default imageType from AL2 to AL2023 for both ECS and EKS compute environments. Amazon Linux 2 has reached EOL for EKS (Nov 2025) and reaches EOL for ECS in June 2026.For EKS compute environments with a launch template, automatically set
userdataTypetoEKS_NODEADMwhen an AL2023 image type is resolved, as required by the AWS Batch API to ensure nodes join the cluster.Update A1 instance validation to also reject ECS_AL2023_NVIDIA and to correctly resolve the feature-flag-defaulted imageType.
Issue # (if applicable)
Closes #35839, closes #37205.
Reason for this change
Amazon Linux 2 has reached EOL for EKS (Nov 2025) and reaches EOL for ECS
in June 2026. The AWS Batch service already defaults to AL2023 for newly
created compute environments, but CDK still hardcodes
ECS_AL2/EKS_AL2when users don't specify an
imageType.Additionally, the
ECS_AL2023_NVIDIA,EKS_AL2023, andEKS_AL2023_NVIDIAimage types supported by the Batch API were missing from the CDK enum definitions.
Related public documentation:
Description of changes
EcsMachineImageType.ECS_AL2023_NVIDIA,EksMachineImageType.EKS_AL2023,and
EksMachineImageType.EKS_AL2023_NVIDIA@aws-cdk/aws-batch:defaultToAL2023that switches thedefault
imageTypefrom AL2 to AL2023 for both ECS and EKS compute environmentsuserdataTypetoEKS_NODEADMwhen an AL2023 image type is resolved, asrequired by the AWS Batch API to ensure nodes join the cluster
ECS_AL2023_NVIDIAand tocorrectly resolve the feature-flag-defaulted
imageTypeDescribe any new or updated permissions being added
None.
Description of how you validated changes
Unit tests cover all new enum values, feature flag on/off for both ECS and EKS,
userdataTypebehavior with launch templates (including the critical scenariowhere the feature flag defaults to AL2023 with a launch template present), and
A1 instance validation. Build passes with 0 errors. 103 batch tests pass,
118 cx-api tests pass.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license