fix(events-targets): cloudwatch logs requires specific input template#20748
fix(events-targets): cloudwatch logs requires specific input template#20748mergify[bot] merged 7 commits intoaws:mainfrom corymhall:corymhall/events-targets/fix-cloudwatch-target
Conversation
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
TheRealAmazonKendra
left a comment
There was a problem hiding this comment.
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.
packages/@aws-cdk/aws-events-targets/test/logs/log-group.test.ts
Outdated
Show resolved
Hide resolved
| }, | ||
| ], | ||
| }); | ||
| const assertionProvider = putEvent.node.tryFindChild('SdkProvider') as AssertionsProvider; |
There was a problem hiding this comment.
Tangential question: do users have to do this for every assertion?
There was a problem hiding this comment.
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.
|
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). |
…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*
The CloudWatch logs log group target requires a very specific input
template. It does not support
inputorinputPathand ifinputTemplateis specified it must be in the format of{"timestamp": <time>, "message": <message>}where both the values for
timestampandmessageare strings.This requirement is not very well documented, the only reference I could
find is in a
Noteon thispage.
This PR adds a new property
logEventand deprecates theeventproperty 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
eventproperty and then went downthe route of providing the new
logEventproperty. Since I already didthe work of creating the validation for
eventI've kept it, but I'mopen to just removing that logic since it is validating a
deprecatedproperty.
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:
New Features
yarn integto deploy the infrastructure and generate the snapshot (i.e.yarn integwithout--dry-run)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license