Skip to content

fix(E2529): count subscription filters per condition scenario - #4917

Merged
kddejong merged 1 commit into
aws-cloudformation:mainfrom
Varshith-Kali:fix-4845-e2529-conditions
Nov 2, 2026
Merged

kddejong merged 1 commit into
aws-cloudformation:mainfrom
Varshith-Kali:fix-4845-e2529-conditions

Conversation

@Varshith-Kali

Copy link
Copy Markdown
Contributor

Fixes #4845

What was wrong

E2529 counted every AWS::Logs::SubscriptionFilter on a log group together, ignoring each resource's Condition. A template with 3 filters under IsProd and 3 under IsDev (where IsDev is Fn::Not of IsProd) was reported as exceeding the 5 filter limit, although at most 3 filters can exist in any deployment. CloudFormation itself deploys such a template cleanly.

What the fix does

E2529 now counts filters per satisfiable condition scenario, using the existing condition solver:

  • Filters without a Condition count in every scenario.
  • Filters with a Condition count only in scenarios where that condition is true, so mutually exclusive filters are never counted together.
  • SAM CloudWatchLogs events inherit the Condition of their function.
  • When conditions cannot be resolved (for example an undefined condition name), the rule falls back to the previous flat count, so it never goes silent.
  • The reported path is the first filter over the limit in the worst scenario.

Test evidence

  • Reproducer from E2529: subscription filters with mutually exclusive Conditions counted together against the 5-per-log-group limit #4845 (3 IsProd + 3 IsDev filters): 1 finding before the fix, 0 after.
  • Control with 6 filters under one condition: still 1 finding.
  • New regression tests in test/unit/rules/resources/lmbd/test_events_log_group_name.py (mutually exclusive conditions, same-condition over limit, unconditional plus conditional over limit, SAM events under mutually exclusive function conditions).
  • test/unit/rules/resources/lmbd/test_events_log_group_name.py: 19 passed.
  • test/unit/rules/resources/lmbd/: 217 passed. ruff check and ruff format clean on the changed files.

@Varshith-Kali

Copy link
Copy Markdown
Contributor Author

Hi maintainers, this is a first-time contribution from an external contributor, so the workflow runs are waiting on approval. The fix is ready for review whenever you have a chance to approve the workflows. Thanks!

E2529 counted every SubscriptionFilter on a log group together, even when their Conditions made them mutually exclusive. A template with 3 IsProd and 3 IsDev filters on one log group was reported as exceeding the 5 filter limit, although at most 3 filters can exist in any deployment.

Count filters per satisfiable condition scenario using the existing condition solver, and report only when the largest scenario exceeds the limit. Unconditional filters count in every scenario, SAM CloudWatchLogs events inherit their function's Condition, and templates with unresolvable Conditions fall back to the previous flat count so the rule never goes silent.

Fixes aws-cloudformation#4845

Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
@kddejong
kddejong force-pushed the fix-4845-e2529-conditions branch from e7c88cd to fc742f6 Compare November 2, 2026 17:42
@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.73%. Comparing base (4c7581a) to head (fc742f6).

Files with missing lines Patch % Lines
...cfnlint/rules/resources/lmbd/EventsLogGroupName.py 86.20% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4917      +/-   ##
==========================================
- Coverage   94.75%   94.73%   -0.02%     
==========================================
  Files         442      442              
  Lines       16105    16130      +25     
  Branches     3125     3133       +8     
==========================================
+ Hits        15260    15281      +21     
- Misses        466      469       +3     
- Partials      379      380       +1     
Flag Coverage Δ
unittests 94.73% <86.20%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kddejong
kddejong merged commit 807e380 into aws-cloudformation:main Nov 2, 2026
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E2529: subscription filters with mutually exclusive Conditions counted together against the 5-per-log-group limit

2 participants