-
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): add support for fieldIndexPolicies in log group L2 Construct #33416
base: main
Are you sure you want to change the base?
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.
(This review is outdated)
Clarification Request |
Hi @yashkh-amzn thank you for contributing! I see the PR is missing integ tests and read me changes. To learn more about our integ test process and how to make them you can refer to this doc. As for README changes they will presumably go here. Note that until the linter and build passes this PR won't show up on our radar to review. Let us know if there is anything else you need clarifying. |
Hey @aaythapa, I had a sync up with your team during the CDK office hours. I was told that the CDK team first wanted to align with the business logic and hence it was okay to submit a PR first for an initial review. Once there would be an alignment, I can update the integ tests and README. |
Ah ok, thanks for letting me know. I'll bring this up with the team and wait for a response |
@@ -629,12 +637,23 @@ export class LogGroup extends LogGroupBase { | |||
Annotations.of(this).addWarningV2('@aws-cdk/aws-logs:propertyNotSupported', `The LogGroupClass property is not supported in the following regions: ${logGroupClassUnsupportedRegions}`); | |||
} | |||
|
|||
const fieldIndexPolicies: any[] = []; | |||
if (props.fieldIndexPolicies) { | |||
if (props.fieldIndexPolicies.length > 1) { |
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.
is this going to be changed in the near future ? if yes then we should remove this check from CDK else we won't know when it will be allowed to set more than 1.
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.
It can be changed in the future but for now this condition does exist - https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.CfnLogGroup.html#fieldindexpolicies. Can't we just remove this condition once we decide to support the array with multiple entries?
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.
}); | ||
}); | ||
|
||
test('set field index policy positive test', () => { |
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.
what is the difference between this test and one above
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.
Good catch! This was a dedup. I'll remove this test case.
private readonly fieldIndexPolicyProps: FieldIndexPolicyProps; | ||
|
||
constructor(props: FieldIndexPolicyProps) { | ||
if (props.fields.length > 20) { |
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.
is this something enforced through CFN handler ?, as it is not mentioned in the documentation
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html#cfn-logs-loggroup-fieldindexpolicies
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 is something which is enforced from the service side. From the official doc - https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatchLogs-Field-Indexing-Syntax.html.
As many as 20 fields can be included in the policy.
@@ -629,12 +637,23 @@ export class LogGroup extends LogGroupBase { | |||
Annotations.of(this).addWarningV2('@aws-cdk/aws-logs:propertyNotSupported', `The LogGroupClass property is not supported in the following regions: ${logGroupClassUnsupportedRegions}`); | |||
} | |||
|
|||
const fieldIndexPolicies: any[] = []; | |||
if (props.fieldIndexPolicies) { |
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 allowed only for STANDARD
log group, can we check the type of log group class.
Ref: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-loggroup.html#cfn-logs-loggroup-fieldindexpolicies
Only log groups in the Standard log class support field index policies.
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.
Sure thing, I can check that and update
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.
Confirmed with the team that we can support Infrequent Access log groups in the future. So to keep the implementation consistent, we will not keep this condition to avoid having to make changes in the future and relying on the service side changes.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #33416 +/- ##
=======================================
Coverage 82.17% 82.17%
=======================================
Files 119 119
Lines 6862 6862
Branches 1158 1158
=======================================
Hits 5639 5639
Misses 1120 1120
Partials 103 103
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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. |
1321c9d
to
8fc94cc
Compare
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Removing the |
Issue # (if applicable)
#33366
Closes #33366
Reason for this change
Field Indexing for CloudWatch Logs (CWL) was launched in Nov 2024. A lot of CWL customers are asking for indexing support in L2 construct. This feature will enable that property under FieldIndexPolicies as a JSON object in the LogGroup construct.
Description of changes
The change here is just populating the
fieldIndexPolicies
property of the LogGroup CFN with the list of fields provided by the user. The format of this property will be like this:Describe any new or updated permissions being added
No new permissions have been added.
Description of how you validated changes
Added unit tests. Will add integ tests after getting a confirmation from the CDK team on the implementation.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license