in aws lambda cloudwatch python boto3 subscription ~ read.

How to list all lambda subscription filters to every Cloudwatch log group that you have

Recently i was working on a project that was listening to all our projects cloduwatch log groups and was forwarding them to Datadog. This adapter was doing some data enrichments of the log records and was also doing some obfuscation of sensitive data. At some point i wanted to find which cloudwatch groups are still not subscribed to my new lambda. It appeared that you can't just go to AWS Lambda UI and look for all cloudwatch log groups that that have subscription to your lambda, so i decided to write a small script that will collect and summarize data about all cloudwatch log groups subscriptions. I'm writing this blog post as a help for me in the future, but feel free to use it as well :)

While writing this script i have discovered a nice hack :

paginator = cloudwatch_logs.get_paginator('describe_log_groups')
for response in paginator.paginate():

It is super useful as AWS SDK returns only 50 results per request and you get pagination out of the box! It's amazing :)

comments powered by Disqus
comments powered by Disqus