Skip to content
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): configure custom subscription filter name #26498

Merged
merged 4 commits into from
Jul 27, 2023

Conversation

tam0ri
Copy link
Contributor

@tam0ri tam0ri commented Jul 25, 2023

Currently, we can't set the subscription filter name as a prop for L2 SubscriptionFilter construct. This PR introduces the new prop filterName. This will let us set a specific name without requiring escape hatches.

Closes #26485


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. labels Jul 25, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team July 25, 2023 16:29
@github-actions github-actions bot added p2 valued-contributor [Pilot] contributed between 6-12 PRs to the CDK labels Jul 25, 2023
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a 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.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation dismissed their stale review July 25, 2023 16:45

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jul 25, 2023
Copy link
Contributor

@kaizencc kaizencc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple comments @tam0ri. Thanks for taking this on!

/**
* The name of the subscription filter.
*/
readonly filterName?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need a default here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your comment! Sorry, I don't understand your intention. What do you mean need a default? As I described in the below conversation, I think it's better that filterName is optional because this can still let CDK/CFn generate physical id (filter name) automatically when this prop isn't specified.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For optional properties, we supply a default value in the documentation so our users know what it means when they don't supply anything:

/**
 * The name of the subscription filter.
 *
 * @default - a generated name is created for you
 */
readonly filterName?: string;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! I aligned with logGroupName and logStreamName.

/**
* Name of the log group.
*
* @default Automatically generated
*/
readonly logGroupName?: string;

/**
* The name of the log stream to create.
*
* The name must be unique within the log group.
*
* @default Automatically generated
*/
readonly logStreamName?: string;

@@ -62,6 +64,7 @@ export class SubscriptionFilter extends Resource {
destinationArn: destProps.arn,
roleArn: destProps.role && destProps.role.roleArn,
filterPattern: props.filterPattern.logPatternString,
filterName: this.physicalName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, won't this change all subscription filters even if they don't supply props.filterName? Why is there a need to propagate the filterName to physicalName this way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your comment!


won't this change all subscription filters even if they don't supply props.filterName?

In my understanding, if we don't specify filterName prop introduced by this PR, this.physicalName will be undefined and then filterName for L1 CfnSubscriptionFilter construct will be also undefined. As a result, FilterName porperty for AWS::Logs::SubscriptionFilter resource in generted CFn template will be omitted. I already tested with the sample app in my env.


Why is there a need to propagate the filterName to physicalName this way

I align this with the similar constructs such as LogGroup, LogStream or MetricFilter as below.

constructor(scope: Construct, id: string, props: LogGroupProps = {}) {
super(scope, id, {
physicalName: props.logGroupName,
});

constructor(scope: Construct, id: string, props: LogStreamProps) {
super(scope, id, {
physicalName: props.logStreamName,
});

constructor(scope: Construct, id: string, props: MetricFilterProps) {
super(scope, id, {
physicalName: props.filterName,
});

From CFn perspective, if we specify FilterName property, this is used as physical id. Shouldn't we propagate the filterName to physicalName?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't, because that would be a breaking change for users who don't specify filterName. The behavior that existed before needs to be maintained, unfortunately.

In practice, if we really want to change the behavior we hide it behind a feature flag. But this ins't important enough to go down that route, imo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait you're saying this.physicalName will be undefined if no filterName is given... hmm maybe thats the case but I would be surprised.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, you are right :)

@mergify mergify bot dismissed kaizencc’s stale review July 26, 2023 14:19

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 6e876f1
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@tam0ri tam0ri requested a review from kaizencc July 27, 2023 08:37
@mergify
Copy link
Contributor

mergify bot commented Jul 27, 2023

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).

@mergify mergify bot merged commit 7ddb305 into aws:main Jul 27, 2023
mergify bot pushed a commit that referenced this pull request Oct 20, 2023
…7621)

In #26498, I injected specific account id and region in integration test snapshot by mistake. This PR replaces them with variables by taking snapshot correctly.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. valued-contributor [Pilot] contributed between 6-12 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(logs): Configure subscription filter name on l2
4 participants