Skip to content

add the function log group id as a dependency to the subscription filter #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

flemay
Copy link

@flemay flemay commented Sep 7, 2017

There is an issue with the serverless-log-forwarding plugin when a new lambda is added to an existing serverless application. The error looks like An error occurred while provisioning your stack: SubscriptionFilterhelloWorld2 - The specified log group does not exist..

So this PR is about adding the function log group id as a dependency to ensure the LogGroup resource exists prior creating the subscription filter resource.

@flemay
Copy link
Author

flemay commented Sep 7, 2017

I've just looked at #7. It might be best to ignore this PR and add the dependency after #7 is merged because the code will all be in place to do something like:

makeSubscriptionFilter(arn, functionName, filterPattern) {
    const functionObject = this.serverless.service.getFunction(functionName);
    const logGroupName = this.provider.naming.getLogGroupName(functionObject.name);
    const functionLogGroupId = this.provider.naming.getLogGroupLogicalId(functionName);
    const filterLogicalId = `SubscriptionFilter${this.provider.naming.getNormalizedFunctionName(functionName)}`;
    const filter = {};
    filter[filterLogicalId] = {
      Type: 'AWS::Logs::SubscriptionFilter',
      Properties: {
        DestinationArn: arn,
        FilterPattern: filterPattern,
        LogGroupName: logGroupName,
      },
      DependsOn: [
        'LogForwardingLambdaPermission',
        functionLogGroupId,
      ],
    };
    return filter;
  }

@flemay
Copy link
Author

flemay commented Sep 7, 2017

I will submit another PR with better testing.

@flemay flemay closed this Sep 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant