-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws-cdk-lib/assertions: Cannot run testing against ProductStack objects #24990
Comments
Hi @thebillest It seems this only happens when Do you have any possible solution or proposed changes? |
According to the ProductStack documentation:
When I go to the aws-cdk-lib/assertions, look at the Annotations class, and work down to the toMessages method (which is what fromStack calls), it appears that it expects to synth and grab artifactIds. These won't work for |
ProductStack works a bit differently from regular stacks: Essentially it just generates a CFN template when you synthesize it. I suggest calling a synth, generating the template which should appear in cdk.out, then running testing against that template. |
While the alternative process of synthesizing a As it currently stands, it's not trivial to render annotations for any |
Any update on this? This is a pretty large gap in ability to unit test stacks? Or at the very least provide a code sample that can achieve a test against a ProductStack even if it's not trivial |
I've figured out a trivial solution to this at least for Template assertions for anyone that finds this. I'm essentially just doing what the aws-cdk class does for loading the template if it's a nested stack.
And for the cdk team I think this can be trivially fixed with something like this where I've bolded the addition:
|
Reopening this issue for #24988 from thebillest
Discussed in #24989
Originally posted by thebillest April 7, 2023
Describe the bug
When trying to perform testing with cdk-nag, according to the methodology listed on this AWS blog, it fails if the stack passed into
Annotations.fromStack()
is aProductStack
.Expected Behavior
The expectation would be that the test would pass/fail based on the CDK-Nag output/findings.
Current Behavior
The mentioned code will fail with an error similar to:
Unable to find artifact with id "TestStackTestProductStack
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.69.0
Framework Version
No response
Node.js Version
19.8.1
OS
macOS Ventura 13.2.1
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: