-
Notifications
You must be signed in to change notification settings - Fork 67
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
fix: Check standard logs in AwsSolutions-CFR3 #1877
base: main
Are you sure you want to change the base?
Conversation
@@ -21,7 +25,10 @@ export default Object.defineProperty( | |||
node.distributionConfig | |||
); | |||
if (distributionConfig.logging == undefined) { | |||
return NagRuleCompliance.NON_COMPLIANT; | |||
pendingDistributions.push(node); | |||
// TODO: If there are no CfnDeliverySource defined, then mark as NON_COMPLIANT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dontirun I'm wondering if you know of a way to check this? I've tried to use Template.fromStack(Stack.of(node))
and then find the resources that way, but that seems to really slow the tests down. Is there a simpler solution that I'm missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there might actually be a better solution here. Can we mark all of the CfnDistribution
's as NOT_APPLICABLE
, add them to a Map and then at the end of the Stack we evaluate and retrospectively mark them as COMPLIANT
or NOT_COMPLIANT
dependent on whether we've seen a CfnDeliverySource
for them? Is there a method of doing that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe we just traverse the entire Stack when we see a CfnDistribution
to check if any CfnDeliverySource
's are present, similar to what we do in WAFv2LoggingEnabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just pushed a commit to match the WAF rule, let me know if you think that's the right solution.
@dontirun Another question which may be out of scope of this PR, but because the logs templates here need to be deployed to Do you know if there's a way to look up this in the Stack? I can see a resource with the ID of |
I've just pushed a commit to resolve SSM parameters as well by traversing the stack again. If it's out of scope for this PR we can just revert the commit, but I think others will also be using parameters to try and avoid any cross-stack reference errors as I detailed above, so it could be useful. |
Fixes #1876
Opening as a draft as the base implementation works, but I've ran into an issue checking if any
CfnDeliverySource
resources are defined in the entire stack. I'll explain in a code comment.I've also had to update
aws-cdk-lib
to2.167.0
, which is the first version to includeoutputFormat
inCfnDeliveryDestination
. As I'm only using this in the tests, am I alright not updating it in thepeerDependencies
as well?