-
Notifications
You must be signed in to change notification settings - Fork 38
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
cdk nag suppression error in cdk pipelines #84
Comments
Thanks for reporting this. Can you share steps to reproduce this? I've tried synthesizing both control-plane and app-plane constructs, but couldn't find the |
Hi, @suhussai thanks for taking a look, the problem is when you add any sbt resources in stack that's deployed in a stage from a cdk pipeline. Since SBT is using cdk nag under the hood of the construct, it appears the cdk pipelines can't synth the resources because it errors out due to the error in the nag rule. This is very limiting especially for multi-account and multi environment deployments.
|
Thanks for listing out the steps. When I
Can you paste the entire the error? I'd like to see where in the SBT code that NagSuppression exists that is causing the error in your example. Assuming that's just a minor thing, I looked at different ways to solve this like enclosing the problematic
Unfortunately, that still didn't work, which is confusing because the NagSuppression shouldn't apply unless that resource exists, but for some reason it does apply, but then it throws an error saying that the related I also tried upgrading the cdk-nag and cdk versions to make sure they weren't the issue, but that didn't help. Given this, I think a simple (but not ideal) solution that should fix this is to use a flag to disable the problematic @tobuck-aws , do you have any thoughts here? |
@suhussai thanks for looking into this further. I got the same resource but I redacted it in case it was a sensitive ID or something. Sorry about that, I should have mentioned that before. I think that is just the tip of the iceberg and if you skip that NagSuppression, there will be several others behind it. That's just my assumption based on how CDK pipelines synthesizes the resources but I could be wrong. Is there a reason the SBT construct needs to use cdk-nag in the first place? As a consumer of the construct, wouldn't it make more sense for me to apply the checks at the various points of the CDK app and resources that are provided by the constructs I'm using? In other words, I just want the resources from the construct, and then let me apply the NagSuppressions at the CDK app level. I'm not sure if that makes sense but it would be nice to have more control than the suppression rules being abstracted away as well. |
I could be mistaken, but when I removed the NagSuppression here: sbt-aws/src/control-plane/auth/cognito-auth.ts Lines 480 to 499 in 76a8d16
I was able to successfully synth the template you sent. Of course, cdk-nag reported several other findings, but it didn't fail with the same error and the findings it showed were related to resources created as part of the template, and not SBT.
We added cdk-nag to the project in order to ensure we were adhering to best practices as we build out the necessary functionality. As for the NagSuppression, they are there to suppress findings that we did not implement and provide documentation/justification for why it was not implemented. |
I updated the NagSuppression as part of this PR #90 and when I tested it using the template you sent, the error did not show up. I'll try and get it merged today. If you have a minute, can you confirm whether the fix worked for you when we've merged it in? |
Auto-closed. Reopening until we get confirmation that the issue has been resolved. |
@suhussai that worked! Thank you very much! This will be very helpful for multi-account deployments! |
Thanks for the feedback and for closing the loop on this. Glad it worked out! |
Describe the bug
Error: Suppression path "/controlplane-stack/AWS679f53fac002430cb0da5b1234567/ServiceRole/Resource" did not match any resource. This can occur when a resource does not exist or if a suppression is applied before a resource is created.
Expected Behavior
sbt control plane deploys in a stack from cdk pipelines
Current Behavior
when i run
cdk synth
it will throw an error. when sbt resources are commented out, it will synth successfully.Reproduction Steps
none
Possible Solution
remove cdk nag and let users of SBT apply nag rules to the resources deployed from the construct
Additional Information/Context
this is a known issue and i've followed these instructions as well:
https://constructs.dev/packages/cdk-nag/v/2.27.136?lang=typescript#suppressing-awscdklibpipelines-violations
cdklabs/cdk-nag#1726
CDK CLI Version
2.151.0
Framework Version
No response
Node.js Version
18
OS
macos
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: