1
votes

I am using cloudwatch to trigger AWS Lambda. Now to create this trigger first of all I have to create rule then I need to add target and then I need to add permission policy to that lambda function. Now the problem is there is a policy length limit(20k) for each lambda function and each cloudwatch trigger increase policy length. So if there are around 60 cloudwatch rules my lambda can still handle all of those events as size is still less than 20k, but after that if rules increase I get http://docs.aws.amazon.com/lambda/latest/dg/API_AddPermission.html "policy length exceed exception error".
I know I can delete the policy by using removePermission method but that is not efficient because if there are around 100 rules present in cloudwatch which are triggering my lambda function then my lambda function can't handle that much amount of policy length.

1

1 Answers

2
votes

This is how I solved it.

Cloudwatch Alerts --> SNS --> Lambda

No subscription, no permissions configuration needed. You can create multiple different SNS notifications if you want to isolate different team based on your alerts.

Steps:

  1. Create SNS with a topic
  2. Send Cloudwatch Alerts to SNS
  3. Subscribe Lambda to that SNS Topic

Receive Alerts to Lambda!

Hope it helps.