Skip to content

chore(mixins-preview): improved find bucket policy#36144

Merged
mergify[bot] merged 4 commits intomainfrom
mrgrain/fix/closest-bucket-policy
Nov 22, 2025
Merged

chore(mixins-preview): improved find bucket policy#36144
mergify[bot] merged 4 commits intomainfrom
mrgrain/fix/closest-bucket-policy

Conversation

@mrgrain
Copy link
Copy Markdown
Contributor

@mrgrain mrgrain commented Nov 21, 2025

Reason for this change

A helper function to reflect on the construct tree to find the closet Bucket Policy for a Bucket.

Description of changes

Implemented a generic function to find two related resources that are "close" to each other. Close is defined here as:

  • the closest (transitive) child matching the predicate
  • the above to the closest parent

Than added a specific function just for bucket. For now this is hand-written and not publicly exposed. If we can identify these kind of connection patterns, we can likely code gen this for all resources.

Describe any new or updated permissions being added

n/a

Description of how you validated changes

Unit tests.

Checklist


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

@mrgrain mrgrain requested a review from a team as a code owner November 21, 2025 14:11
@github-actions github-actions bot added the p2 label Nov 21, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team November 21, 2025 14:11
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Nov 21, 2025
@mrgrain mrgrain force-pushed the mrgrain/fix/closest-bucket-policy branch from a67e432 to f6ff948 Compare November 21, 2025 15:20
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 21, 2025
@mrgrain mrgrain added the pr/do-not-merge This PR should not be merged at this time. label Nov 21, 2025
while (ancestor && ancestorDistance < closestDistance) {
// Check all siblings and their descendants at this ancestor level
for (const sibling of ancestor.node.children) {
searchChildren(sibling, ancestorDistance);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will probably lead to us re-treading ground in a lot of places, but it does fix the problem the previous implementation had with not finding policies that were the children of a parent's sibling (or in other similar places).
If we are ok with duplicated work for the sake of completeness then I am fine approving this iteration, if not we may want to add some way to check if a node has been visited already.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 21, 2025
@mrgrain mrgrain removed the pr/do-not-merge This PR should not be merged at this time. label Nov 22, 2025
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Nov 22, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit fc2f717 into main Nov 22, 2025
23 of 24 checks passed
@mergify mergify bot deleted the mrgrain/fix/closest-bucket-policy branch November 22, 2025 17:07
@github-actions
Copy link
Copy Markdown
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

contribution/core This is a PR that came from AWS. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants