Skip to content

fix(cloudformation-diff): security group rule diff ignores which group a rule belongs to - #1872

Merged
aws-cdk-automation merged 1 commit into
aws:mainfrom
Adityaj0:fix/security-group-rule-diff-ignores-group-id
Aug 24, 2026
Merged

fix(cloudformation-diff): security group rule diff ignores which group a rule belongs to#1872
aws-cdk-automation merged 1 commit into
aws:mainfrom
Adityaj0:fix/security-group-rule-diff-ignores-group-id

Conversation

@Adityaj0

Copy link
Copy Markdown
Contributor

Closes #1871

Reason for this change

SecurityGroupRule.equal() compares ipProtocol, fromPort, toPort, and peer, but not groupId. This method is used to match rules between the old and new template when computing ingress/egress diffs.

As a result, a rule that moves from one security group to a different one — while keeping the same protocol/port/peer — is treated as unchanged, and the diff silently drops both the removal from the old group and the addition to the new group. This can mask a real permission change (e.g. widening which resource has a given network rule) from cdk diff output.

Description of changes

Add groupId to the equality comparison in SecurityGroupRule.equal(), so a rule moving between groups is correctly reported as a removal + addition.

Description of how you validated changes

Added a test (detect a rule moving from one security group to a different one) that moves an identical-shaped ingress rule from WebSG to DbSG and asserts the diff reports it as a removal from WebSG and an addition to DbSG.

PASS test/network/detect-changes.test.ts
  ✓ detect addition of all types of rules
  ✓ detect a rule moving from one security group to a different one

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.

…p a rule belongs to

SecurityGroupRule.equal() compared protocol/port/peer but not groupId, so a
rule with the same shape moving from one security group to another was
reported as unchanged instead of a removal + addition.
@Adityaj0
Adityaj0 deployed to automation August 22, 2026 01:56 — with GitHub Actions Active
@Adityaj0
Adityaj0 deployed to automation August 22, 2026 01:56 — with GitHub Actions Active
@github-actions github-actions Bot added the p2 label Aug 22, 2026
@Adityaj0
Adityaj0 deployed to integ-approval August 22, 2026 01:56 — with GitHub Actions Active
@aws-cdk-automation
aws-cdk-automation requested a review from a team August 22, 2026 01:56
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.10%. Comparing base (a4c0282) to head (0473a63).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1872      +/-   ##
==========================================
+ Coverage   90.90%   91.10%   +0.19%     
==========================================
  Files          80       80              
  Lines       12250    12205      -45     
  Branches     1754     1742      -12     
==========================================
- Hits        11136    11119      -17     
+ Misses       1077     1050      -27     
+ Partials       37       36       -1     
Flag Coverage Δ
suite.unit 91.10% <ø> (+0.19%) ⬆️

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aws-cdk-automation
aws-cdk-automation added this pull request to the merge queue Aug 24, 2026
Merged via the queue into aws:main with commit cfe3f82 Aug 24, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cloudformation-diff: security group rule diff ignores which group a rule belongs to

4 participants