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

fix(events-targets): cloudwatch logs requires specific input template #20748

Merged
merged 7 commits into from
Jun 20, 2022
Merged

fix(events-targets): cloudwatch logs requires specific input template #20748

merged 7 commits into from
Jun 20, 2022

Conversation

corymhall
Copy link
Contributor

@corymhall corymhall commented Jun 15, 2022

The CloudWatch logs log group target requires a very specific input
template. It does not support input or inputPath and if
inputTemplate is specified it must be in the format of

{"timestamp": <time>, "message": <message>}

where both the values for timestamp and message are strings.

This requirement is not very well documented, the only reference I could
find is in a Note on this
page.

This PR adds a new property logEvent and deprecates the event
property to ensure that if the user adds an event input that it uses the
correct format. While working on this PR is started by adding some
validation if the user provides the event property and then went down
the route of providing the new logEvent property. Since I already did
the work of creating the validation for event I've kept it, but I'm
open to just removing that logic since it is validating a deprecated
property.

I've also added an integration test that asserts that the expected
message is written to the log group.

fixes #19451


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • 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

The CloudWatch logs log group target requires a very specific input
template. It does not support `input` or `inputPath` and if
`inputTemplate` is specified it must be in the format of

`{"timestamp": <time>, "message": <message>}`

where both the values for `timestamp` and `message` are strings.

This requirement is not very well documented, the only reference I could
find is in a `Note` on this
[page](https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutTargets.html).

This PR adds a new property `logEvent` and deprecates the `event`
property to ensure that if the user adds an event input that it uses the
correct format. While working on this PR is started by adding some
validation if the user provides the `event` property and then went down
the route of providing the new `logEvent` property. Since I already did
the work of creating the validation for `event` I've kept it, but I'm
open to just removing that logic since it is validating a `deprecated`
property.

I've also added an integration test that asserts that the expected
message is written to the log group.

fixes #19451
@gitpod-io
Copy link

gitpod-io bot commented Jun 15, 2022

@github-actions github-actions bot added bug This issue is a bug. effort/small Small work item – less than a day of effort p1 labels Jun 15, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team June 15, 2022 13:19
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jun 15, 2022
Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

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

I like this change quite a lot. Just one question about the tests below but also, I think we may want a README update for this.

},
],
});
const assertionProvider = putEvent.node.tryFindChild('SdkProvider') as AssertionsProvider;
Copy link
Contributor

Choose a reason for hiding this comment

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

Tangential question: do users have to do this for every assertion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, and i've added an item to our list to expose this ability on the AssertionsProvider. It's supposed to figure out the permissions based on the API call, but I keep running into cases where it can't figure it out.

@mergify
Copy link
Contributor

mergify bot commented Jun 20, 2022

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify mergify bot merged commit 26ff3c7 into aws:main Jun 20, 2022
@mergify
Copy link
Contributor

mergify bot commented Jun 20, 2022

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

daschaa pushed a commit to daschaa/aws-cdk that referenced this pull request Jul 9, 2022
…aws#20748)

The CloudWatch logs log group target requires a very specific input
template. It does not support `input` or `inputPath` and if
`inputTemplate` is specified it must be in the format of

`{"timestamp": <time>, "message": <message>}`

where both the values for `timestamp` and `message` are strings.

This requirement is not very well documented, the only reference I could
find is in a `Note` on this
[page](https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutTargets.html).

This PR adds a new property `logEvent` and deprecates the `event`
property to ensure that if the user adds an event input that it uses the
correct format. While working on this PR is started by adding some
validation if the user provides the `event` property and then went down
the route of providing the new `logEvent` property. Since I already did
the work of creating the validation for `event` I've kept it, but I'm
open to just removing that logic since it is validating a `deprecated`
property.

I've also added an integration test that asserts that the expected
message is written to the log group.

fixes aws#19451


----

### 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

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] 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
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws_events_targets.CloudWatchLogGroup): unable to add aws_events.RuleTargetInput.from_object
4 participants