assertions: Allow to use wildcard when specifying constructPath of Annotations #25803
Open
1 of 2 tasks
Labels
@aws-cdk/assertions
Related to the @aws-cdk/assertv2 package
effort/small
Small work item – less than a day of effort
feature-request
A feature should be added or improved.
p2
Describe the feature
Currently we can use methods like
Annotations.hasError
for either 1. all the constructs or 2. one specific construct.Now it will be much more useful if we can specify more granular match like prefix match.
Use Case
I'd like to do more granular test on a specific construct. It would be ideal if we can use something like glob pattern to specify the construct path.
For example, when using with cdk-nag, we can check the vulnerabilities only for a specific construct and its children.
Proposed Solution
Use minimatch library here instead of
v.id === path
.minimatch
is already used inaws-cdk-lib
so it should not affect bundle size.aws-cdk/packages/aws-cdk-lib/assertions/lib/private/messages.ts
Lines 56 to 58 in d99733f
However, because we can use special characters such as * or + in a construct id, the syntax of minimatch conflicts with them. We have to consider a workaround to introduce this feature without breaking changes.
Other Information
No response
Acknowledgements
CDK version used
2.81.0
Environment details (OS name and version, etc.)
macOS
The text was updated successfully, but these errors were encountered: