amplify-education / serverless-log-forwarding

Serverless plugin for forwarding CloudWatch logs to another Lambda function.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Forwarding logs to Lambda on current project's deployment

kiesel opened this issue · comments

I'd like to use this plugin to forward logs to a common function that is part of the project itself. There are two problems that need to get resolved for this to work:

  1. Addressing of the function
    Today, one needs to write the full ARN - including region & accountId - into the configuration. I'd like to use the function name to address the function, so it'd be unnecessary to hardcode the other values
  2. Omit a log subscription for the target function
    The so-configured target function should be omitted from the logging itself, as this would create a recursion.

What do you think?

  1. That sounds like a useful feature. If you have time to make a PR then we can definitely get that added in.

  2. You can handle this by putting the target function into a separate Serverless project and deploy it independently without using the plugin. This would also help you reuse it for other Serverless projects in the future.

FYI, found a work around

...

functions:
  logForwarder:
    handler: logforwarder.handler
    logForwarding:
      enabled: false

plugins:
  - serverless-log-forwarding

custom:
  logForwarding:
    destinationARN: !GetAtt LogForwarderLambdaFunction.Arn

...

This has exactly the same behavior that you are asking.

Awesome, then this request is obsolete.