0
votes

Is it possible to trigger a lambda in AWS with the input being a whole CloudWatch log stream? I have been able to trigger my lambda with a Subscription Filter but this is per log event, so it is triggered multiple times. I'd ideally like my lambda to be triggered only when my application that creates this log stream has finished running and the log stream is not being written to anymore. Otherwise, I'd have to change the code of my application to put everything I need into one log line for the lambda to receive via the Subscription Filter.

My end goal is to have the information I need from the logs be sent in an email via SES. The problem I have is that this information is not logged out all in one log line, but several.

1

1 Answers

0
votes

Now it is finally possible with the new (12.11.2020) logs-extension feature: https://aws.amazon.com/blogs/compute/using-aws-lambda-extensions-to-send-logs-to-custom-destinations/

You can aggregate the logs in the extension, and then send it only when you get a SHUTDOWN event. The log-groups are aggregated by containers, i.e. a new log group is created only when a lambda is started on a new cintainer. So aggregating your logs based on "warm invocations" is equivalent to log-group.

You may use my open-source tool as an example of the interaction between the LambdaService and the extension.