-
Notifications
You must be signed in to change notification settings - Fork 54
Description
Description
When attempting to migrate from your old ingest Lambda function (see #267), we needed to update all existing CloudWach log group subscriptions. To do this, we ran newrelic-lambda subscriptions install --function newrelic-lambda subscriptions install.
However, this command had no effect at all. Upon reviewing the source code, we found a flaw in its logic.
newrelic-lambda-cli/newrelic_lambda_cli/subscriptions.py
Lines 132 to 142 in 6b5d8d4
| click.echo( | |
| "Found log subscription for '%s', verifying configuration" % function_name | |
| ) | |
| newrelic_filter = newrelic_filters[0] | |
| if newrelic_filter["filterPattern"] != input.filter_pattern: | |
| return _remove_subscription_filter( | |
| input.session, function_name, newrelic_filter["filterName"] | |
| ) and _create_subscription_filter( | |
| input.session, function_name, destination_arn, input.filter_pattern | |
| ) | |
| return True |
As you can see, if a NewRelicLogStreaming subscription filter already exists, it will only re-create it if the filter pattern changes. In our case, only the destination arn was changing, and thus the CLI incorrectly did not fix any of them.
As a workaround, we ran the command twice, once with a dummy --filter-pattern parameter and once without, in order to get it to properly re-create the subscription filter.
Steps to Reproduce
See above.
Expected Behavior
The newrelic-lambda subscriptions install must re-create the subscription filter if either the filter pattern or destination arn are wrong.
Relevant Logs / Console output
n/a
Your Environment
n/a