fix(cloudformation-diff): security group rule diff ignores which group a rule belongs to - #1872
Open
Adityaj0 wants to merge 1 commit into
Open
Conversation
…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
requested a deployment
to
integ-approval
August 22, 2026 01:56 — with
GitHub Actions
Waiting
aws-cdk-automation
enabled auto-merge
August 22, 2026 01:56
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Closes #1871
Reason for this change
SecurityGroupRule.equal()comparesipProtocol,fromPort,toPort, andpeer, but notgroupId. 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 diffoutput.Description of changes
Add
groupIdto the equality comparison inSecurityGroupRule.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 fromWebSGtoDbSGand asserts the diff reports it as a removal fromWebSGand an addition toDbSG.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.