feat(core): add scope to IPolicyValidationContext#38006
Open
kaizencc wants to merge 2 commits into
Open
Conversation
Adds an optional `scope` property to `IPolicyValidationContext` (and the deprecated `IPolicyValidationContextBeta1`) that exposes the root construct of the app being validated. This allows plugins to walk the construct tree for typed L1 property access and token resolution via `Stack.of(node).resolve()` instead of re-parsing JSON templates. The field is optional to preserve backwards compatibility — existing plugins continue to work unchanged.
Contributor
|
PRs without a linked issue will receive lower priority for review and merging. Please update the description to follow the PR template and include a line like |
aws-cdk-automation
previously requested changes
May 26, 2026
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
rix0rrr
approved these changes
May 27, 2026
Contributor
rix0rrr
left a comment
There was a problem hiding this comment.
Conditional approval, I do want you to change the contract slightly.
| * | ||
| * @default - not provided | ||
| */ | ||
| readonly scope?: IConstruct; |
Contributor
There was a problem hiding this comment.
Suggested change
| readonly scope?: IConstruct; | |
| readonly appConstruct: IConstruct; |
Two changes:
- Always present. It's something that we always guarantee to plugin writers that exists. So it's a stronger guarantee than optional, which is fine. If this causes a
jsii-diffproblem, you can silence it. - If you call it
scope, it makes me think that we get called multiple times at different points in the tree, but that's not what it is. So name it more strongly to what it represent.
Address review feedback: - Rename `scope` to `appConstruct` to better convey that this is the app root, not a per-invocation scope - Make the property required since we always guarantee it to plugin writers
8b3f4ff to
4bbccdb
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.
Summary
scopeproperty toIPolicyValidationContext(and the deprecatedIPolicyValidationContextBeta1) exposing the root construct of the app being validated.Stack.of(node).resolve(), rather than re-parsing synthesized JSON templates.Test plan
validate context includes scope as the root construct— verifies plugin receives the App asscopeexpect.objectContaining(they were exact-matching the context shape)