'How to prevent recreation of subscription filters during serverless deployment
I have a function(lambda) that is subscribed to cloudwatch logs of another function. The IaC for this looks like this:
ReadLoginLogs:
handler: src/API.readFnLogs
events:
- cloudwatchLog:
logGroup: /aws/lambda/project-xxx-api-${self:custom.stage}-function1
filter: 'THIS_DATA'
The subscription filter is already created for this in AWS but during deployment, i get the following error:
Only 2 subscription filters can be configured per log group. There are subscription filters defined outside of the service definition for "/aws/lambda/project-xxx-api" that have to be deleted manually.
I'm not sure why serverless keeps attempting to recreate the subscription. How do I prevent serverless from attempting to recreate the subscription during deployment and just ignore creating it if it's already there?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|