Member-only story
CloudWatch Lambda Subscription Filter (CDK-Demo)
Filtering AWS CloudWatch logs and forwarding to AWS Lambda.

In this article, I want to show you how we can use the AWS CloudWatch subscription filter for filtering logs and forward them to a lambda function.
Simple Usecase
Filter critical app errors and send a real-time notification to a Slack channel with error information.
Note that I use AWS CDK for creating the infrastructure.
Create a CloudWatch Log Group
We need to set up a CloudWatch log group for receiving log events from applications. After that, you need to configure your application to send logs to this log group.
Create a Lambda Function for Processing Logs
In this step, we create a Lambda function for processing application logs that come from the CloudWatch subscription filter.