Skip to content

newrelic-lambda subscriptions install does not consider destination arn of existing subscription filter #357

@rittneje

Description

@rittneje

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.

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

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions