serverless-plugin-log-subscription
serverless-plugin-log-subscription copied to clipboard
Adding second log subscription results in Resource limit exceeded
Our AWS account supports up to two log subscriptions (I think this is now default?) and I can manually attach up to two to a cloudwatch log group.
We currently have a single log subscription attached to many functions using this plugin, our serverless code looks like:
custom:
logSubscription:
enabled: true
destinationArn: <arn>
We now want to attach a second log subscription to our functions, and wanted to do so like such:
custom:
logSubscription:
- enabled: true
destinationArn: <arn>
- enabled: true
destinationArn: <arn>
However, doing so results in problems deploying. When moving to this directly, we always receive the error:
PostUnderscoredeploySubscriptionFilter0 - Resource limit exceeded. (Service: AWSLogs; Status Code: 400; Error Code: LimitExceededException;)
I have found a work-around; we can make this change in two steps. First update the serverless spec so that the logSubscription is the list format, like so:
custom:
logSubscription:
- enabled: true
destinationArn: <arn>
Then deploy all instances of the function.
Then update the serverless spec to add the second item, like so:
custom:
logSubscription:
- enabled: true
destinationArn: <arn>
- enabled: true
destinationArn: <arn>
Then deployments will work fine.
I believe issue in making this change directly is that the name changes for the existing subscription, to add a suffix of the list index. https://github.com/dougmoscrop/serverless-plugin-log-subscription/blob/master/serverless-plugin-log-subscription.js#L31 Cloudformation appears to attempt to create both new subscriptions before destroying the old subscription. This could perhaps be fixed by only adding the suffix if index>0 (but unsure how that would impact other users who currently have two items).