Skip to content

feat(batch): switch default imageType to ECS_AL2023 for EC2 compute environments (under feature flag)#37220

Open
alpin87 wants to merge 2 commits intoaws:mainfrom
alpin87:feat/batch-default-al2023
Open

feat(batch): switch default imageType to ECS_AL2023 for EC2 compute environments (under feature flag)#37220
alpin87 wants to merge 2 commits intoaws:mainfrom
alpin87:feat/batch-default-al2023

Conversation

@alpin87
Copy link

@alpin87 alpin87 commented Mar 11, 2026

Closes #37205

Reason for this change

Amazon Linux 2 (AL2) is reaching EOL in June 2026. AWS Batch compute environments that do not explicitly specify imageType currently default to ECS_AL2, which is deprecated. New environments should use ECS_AL2023 by default.

Description of changes

Introduced a new feature flag @aws-cdk/aws-batch:defaultEcsAL2023 that switches the default imageType fallback from ECS_AL2 to ECS_AL2023 in ManagedEc2EcsComputeEnvironment.

  • Added feature flag BATCH_DEFAULT_ECS_AL2023 in cx-api/lib/features.ts
  • Updated the fallback logic in managed-compute-environment.ts to use ECS_AL2023 when the flag is enabled
  • Updated JSDoc @default comments on images and imageType properties
  • Auto-generated FEATURE_FLAGS.md and recommended-feature-flags.json updated via build

A feature flag is used instead of a direct default change to avoid breaking existing stacks (behavior change in CloudFormation template).

Describe any new or updated permissions being added

None.

Description of how you validated changes

  • Added two unit tests in managed-compute-environment.test.ts:
    • Feature flag OFF: verifies default imageType remains ECS_AL2 (backward compat)
    • Feature flag ON: verifies default imageType becomes ECS_AL2023
  • All 232 existing aws-batch tests pass
    Note: global coverage threshold failure is a pre-existing issue in the repository, unrelated to this change.

@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 labels Mar 11, 2026
@aws-cdk-automation aws-cdk-automation requested a review from a team March 11, 2026 05:35
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@alpin87 alpin87 changed the title feat(aws-batch): switch default imageType to ECS_AL2023 for EC2 compute environments (under feature flag) feat(batch): switch default imageType to ECS_AL2023 for EC2 compute environments (under feature flag) Mar 11, 2026
@alpin87
Copy link
Author

alpin87 commented Mar 11, 2026

Exemption Request

This change introduces a feature flag (@aws-cdk/aws-batch:defaultEcsAL2023) that only affects the default value of imageType in the CloudFormation template when no explicit value is provided.

The behavior change is:

  • Flag OFF (default): imageType falls back to ECS_AL2 — identical to the current behavior, no template diff
  • Flag ON: imageType falls back to ECS_AL2023 — existing integration tests already cover ECS_AL2023 explicitly (e.g., line 935 in managed-compute-environment.test.ts)

An integration test would require a real AWS deployment and the change is fully covered by the two new unit tests added in this PR. Requesting an exemption from the integration test requirement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(aws-batch): Switch to AL2023 in the default AMI for EC2 compute environments

2 participants