-
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
feat(logs): support DataProtectionPolicy in LogGroup construct #23402
Conversation
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.
Thanks for the PR @kchg!
As it is now, this PR doesn't introduce any functionality that isn't already easily achievable through escape hatches. So, instead of asking our users to fully understand how to build a data protection policy and supply that directly as an object, it would be great to abstract this such that the dataProtectionPolicy
prop takes in a class with a name like DataProtectionPolicy
that can contain one or more configurable DataPolicyStatement
s. See our Policy
and PolicyStatement
classes in our IAM module for reference on what this might look like 🙂 These classes contain methods to modify existing statements, and ways to add statements to an existing policy. I think these methods would be useful in this case as well. Open to thoughts/suggestions!
Thanks for the feedback @peterwoodworth! I'll make some changes here to abstract away the details of creating a data protection policy, so that users can just provide a list of data identifiers and any audit destinations. |
This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week. |
d820ef6
to
232799b
Compare
Pull request has been modified.
9edc82e
to
9e531b9
Compare
Hi @peterwoodworth, this PR should allow users to add a data protection policy to a log group without knowing the actual structure of the policy. Could you please review this? Thanks. |
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.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
1 similar comment
This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state. |
Hi @corymhall, thank you for the review, I've made changes or addressed each comment from your review, please let me know what you think. |
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.
Looking good! Just a couple more suggestions.
/** | ||
* Represents a data protection policy in a log group. | ||
*/ | ||
export class DataProtectionPolicy { |
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.
Yeah on second look I was thinking about extending construct because the constructor took a scope
argument. I think we should modify this API a bit to be something like.
class DataProtectionPolicy {
constructor(props: DataProtectionPolicyProps) {
...
}
public bind(scope: Construct): DataProtectionPolicyConfig {
...
}
}
and then
new CfnLogGroup(this, 'Resource', {
...,
dataProtectionPolicy: props.dataProtectionPolicy.bind(this),
/** | ||
* Data Protection Policy for this log group. | ||
* | ||
* @default null |
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.
* @default null | |
* @default - no data protection policy |
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.
Updated.
- Add bind method to remove need for scope from constructor - Made DataIdentifier required and add check for length
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.
Looking good! Just a couple of minor things
* @param scope the Construct scope | ||
* @returns the data protection policy | ||
*/ | ||
public bind(scope: Construct): DataProtectionPolicyConfig { |
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.
Since this is a public API, we should allow for non-breaking changes that we might need to
make in the future. We can either make this an internal API by adding
@internal
and changing the name to _bind()
or we can add a second optional
props argument that is empty for now. public bind(scope: Construct, props: DataProtectionPolicyBindProps = {})
If you don't think there is any use case for using this outside of the internal
library usage then I would recommend going with @internal
.
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.
Updated to _bind()
@@ -0,0 +1,28 @@ | |||
"use strict"; |
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.
This file should not have been git ignored. Can you check?
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.
Looks like the .gitignore was updated since the commit adding these files, I've removed this file from the PR.
@@ -0,0 +1 @@ | |||
export {}; |
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.
This file should have been git ignored, can you check?
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.
Removed this file.
- Made the bind() method internal with _bind() - Removed gitignored files
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Hey, thanks for the great PR! A question: this PR introduces the ability to associate a DataProtectionPolicy to a LogGroup when you create it via the
But then I am unable to do something like Are there any plans to support it or Is there any way to make it work that I cannot see? I tried creating a Again, thanks a lot! |
@renatoargh Did you find any workaround for that use case? Thanks! |
Any idea if this is possible somehow? I'm also using CDK for our infrastructure and don't see a way to set a custom log group or simply modify the existing one on the lambda to add that DataProtectionPolicy. |
If just someone gets to the same PR here, I finally was able to implement it using AWSCustomResource executing a AWSSDKCall when the CloudFormation is created ( |
Sensitive data protection for CloudWatch Logs was launched at re:Invent 2022. This feature will enable that property under DataProtectionPolicy as a JSON object in the LogGroup construct.
Use case: A data protection policy can help safeguard sensitive data that's ingested by the log group by auditing and masking the sensitive log data. When a user who does not have permission to view masked data views a log event that includes masked data, the sensitive data is replaced by asterisks.
closes #23399
All Submissions:
Adding new Construct Runtime Dependencies:
New Features
yarn integ
to deploy the infrastructure and generate the snapshot (i.e.yarn integ
without--dry-run
)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license