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(aws-ec2): add support for custom logformat in vpc flow logs #16279

Closed
wants to merge 6 commits into from
Closed

feat(aws-ec2): add support for custom logformat in vpc flow logs #16279

wants to merge 6 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 30, 2021

Adds support for a custom logFormat in the vpc flow logs options.

See "Custom Format" on this page: https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html

fixes #19316

@gitpod-io
Copy link

gitpod-io bot commented Aug 30, 2021

@ghost ghost changed the title feat(aws-ec2): add support for custom logFormat in vpc flow logs feat(aws-ec2): add support for custom logformat in vpc flow logs Aug 30, 2021
@peterwoodworth peterwoodworth added @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud effort/small Small work item – less than a day of effort p2 labels Sep 1, 2021
@ghost
Copy link
Author

ghost commented Sep 2, 2021

@peterwoodworth Thanks for taking a look.

Should I document this in a Readme like the PR linter says or it's not necessary?

@peterwoodworth peterwoodworth added the pr-linter/exempt-readme The PR linter will not require README changes label Sep 2, 2021
@peterwoodworth
Copy link
Contributor

No need to update the readme anymore :)

I've marked this as p2, so it may be a while before it gets reviewed. Are you aware of escape hatches which help you work around this issue in the meantime?

@ghost
Copy link
Author

ghost commented Sep 2, 2021

Yup, I'm alright with escape hatches for now.
Thanks!

Copy link

@mnanchev mnanchev left a comment

Choose a reason for hiding this comment

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

Looks good to me :)

@ghost
Copy link
Author

ghost commented Nov 18, 2021

@mnanchev I fixed the test that had a conflict.
Any chance this can get merged in?

xavierbuspatrol added 2 commits November 18, 2021 16:10
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: d4f2160
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

Copy link
Contributor

@corymhall corymhall left a comment

Choose a reason for hiding this comment

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

@xavierbuspatrol thanks for the PR and sorry it took so long to review!

*
* @default - No custom log format options provided.
*/
readonly logFormat?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the log format expects specific values, I think it makes sense to turn this into something that is better typed and can provide useful information to the user. Maybe something like

readonly customLogFormatFields?: LogFormatField[];

And then LogFormat could be something like

export class LogFormatField {
  /**
    * The source port of the traffic.
    */
  public static readonly SRC_PORT = new LogFormatField('${srcport'});

  public static custom(field: string): LogFormatField {
    return new LogFormatField(`\${${field}}`);
  }

  constructor(public readonly value: string) {}

}

new FlowLog(stack, 'FlowLogs', {
  customLogFormatFields: [
    LogFormatField.SRC_PORT,
    LogFormatField.custom('dstport'),
    ...
  ]
}

Copy link
Author

Choose a reason for hiding this comment

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

Good feedback, will work on it

@corymhall corymhall removed the pr-linter/exempt-readme The PR linter will not require README changes label Feb 16, 2022
@aws-cdk-automation
Copy link
Collaborator

This PR has been in CHANGES REQUESTED for 21 days, and looks abandoned. It will be closed in 10 days if no further commits are pushed to it.

@github-actions
Copy link

This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.

@github-actions github-actions bot added the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Apr 20, 2022
@github-actions github-actions bot closed this Apr 20, 2022
watany-dev added a commit to watany-dev/aws-cdk that referenced this pull request Oct 9, 2022
watany-dev added a commit to watany-dev/aws-cdk that referenced this pull request Oct 15, 2022
mergify bot pushed a commit that referenced this pull request Nov 11, 2022
refer to #16279 and #16279 (comment).  The difference is below

- I don't think you need custom for `LogFormatField`. "custom" in the document below does not mean that the user can specify any Key. It means that you can specify any Key of "Available fields" with a space-separated string.
https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html#flow-logs-fields


fixes #19316

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FlowLog: add support for log_format parameter
4 participants