-
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
fix(events-targets): cloudwatch logs requires specific input template #20748
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
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.
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.
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?
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.
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
input
orinputPath
and ifinputTemplate
is specified it must be in the format of{"timestamp": <time>, "message": <message>}
where both the values for
timestamp
andmessage
are strings.This requirement is not very well documented, the only reference I could
find is in a
Note
on thispage.
This PR adds a new property
logEvent
and deprecates theevent
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 downthe route of providing the new
logEvent
property. Since I already didthe work of creating the validation for
event
I've kept it, but I'mopen 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:
New Features
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