fix(ecs): validate environment variable limit in container definitions - #38228
Open
sanyamk23 wants to merge 3 commits into
Open
fix(ecs): validate environment variable limit in container definitions#38228sanyamk23 wants to merge 3 commits into
sanyamk23 wants to merge 3 commits into
Conversation
aws-cdk-automation
previously requested changes
Jul 1, 2026
aws-cdk-automation
dismissed
their stale review
July 2, 2026 13:47
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
1 task
sanyamk23
force-pushed
the
fix/ecs-env-var-limit-validation
branch
from
July 31, 2026 16:08
72ba15c to
df1d55d
Compare
sanyamk23
force-pushed
the
fix/ecs-env-var-limit-validation
branch
from
August 2, 2026 20:10
df1d55d to
5adcc39
Compare
sanyamk23
force-pushed
the
fix/ecs-env-var-limit-validation
branch
from
August 3, 2026 18:52
5adcc39 to
df1d55d
Compare
abidhasan-aws
temporarily deployed
to
automation
August 7, 2026 11:10 — with
GitHub Actions
Inactive
abidhasan-aws
temporarily deployed
to
automation
August 7, 2026 11:11 — with
GitHub Actions
Inactive
Author
|
Full CI including build is green. Ready for review. |
Author
|
Hi @otaviomacedo, I added validation for the ECS environment variable limit so deployments do not fail silently. Would appreciate a review. |
sanyamk23
force-pushed
the
fix/ecs-env-var-limit-validation
branch
from
August 17, 2026 12:19
51530b3 to
325bf69
Compare
sanyamk23
force-pushed
the
fix/ecs-env-var-limit-validation
branch
from
August 17, 2026 19:53
325bf69 to
81e5fdb
Compare
…ross-repo PRs When the GitHub API returns a 404 for the list reviews endpoint (which can happen for cross-repo PRs from forks or when the PROJEN_GITHUB_TOKEN lacks access to the source repository), treat it as no existing reviews rather than crashing the entire validate-pr job. Previously, the 404 error would propagate up to run().catch() in index.ts, causing the process to exit with code 1 and failing the workflow.
ECS task definitions silently fail when a container has more than 100 environment variables — CloudFormation creates the task definition with an empty environment array instead of failing with an error. This adds synth-time validation in both the ContainerDefinition constructor and the addEnvironment() method to fail fast with a clear error message when the 100 environment variable limit is exceeded. Fixes aws#38225
Add integration test verifying that exactly 100 environment variables can be added to a container definition without errors, and that the synthesized CloudFormation template correctly includes all variables. Also fix lint error (extra blank line) in unit test file.
sanyamk23
force-pushed
the
fix/ecs-env-var-limit-validation
branch
from
August 17, 2026 19:58
81e5fdb to
48ecb08
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Fixes #38225
ECS task definitions silently fail when a container has more than 100 environment variables. CloudFormation creates the task definition with an empty environment array instead of failing with an error, which causes deployments to "succeed" while the application fails at runtime due to missing configuration.
Solution
Add synth-time validation in both the ContainerDefinition constructor and the addEnvironment() method to fail fast with a clear error message when the 100 environment variable limit is exceeded.
This follows the pattern used for other validations in the same file (for example, memory limit checks and port mapping validation) and uses ValidationError with a descriptive error code.
Testing
Added 3 unit tests:
All 109 existing tests pass, confirming no regressions.
Considerations
This validation was added without a feature flag because input with more than 100 environment variables was never actually accepted by ECS at deploy time. CloudFormation silently creates an empty environment array. This is fail-fast synth-time validation for previously broken input, not a breaking change to working behavior.