I want to set multiple logs as triggers in the serverless cloudwatch log event.

Asked 2 years ago, Updated 2 years ago, 85 views

Using the official documentation below, we were able to trigger the cloudwatch log and fire the event.
https://serverless.com/framework/docs/providers/aws/events/cloudwatch-log/

On the web console, you can set triggers for multiple cloudwatch logs, so I wanted to implement the same thing in code, so I wrote as follows, but it didn't work.

-cloudwatchLog:
          logGroup: '/aws/lambda/hello1'
          filter: '{$.userIdentity.type=Root}'

      - cloudwatchLog:
          logGroup: '/aws/lambda/hello2'
          filter: '{$.userIdentity.type=Root}'

I have tried several similar formats, but it is difficult to register two for one lambda.

Currently, we avoid by generating multiple lambda functions and setting a single trigger for each, but the amount of code we want to set as a trigger has increased by a few minutes, making it very difficult to see. (The lambda function is also increasing.)

If you can do something like the title, it's very easy to manage.

Thank you for your cooperation.

aws aws-lambda lambda

2022-09-30 14:42

1 Answers

It worked with this description.
However, if you look at the AWS Lambda web console, you should be aware that the trigger does not appear to be installed, but it is actually working as expected.

serverless.yml

 functions:
  MyCloudWatchLog:
    handler —Handler.hello
    events:
      - cloudwatchLog: '/aws/lambda/hello1'
      - cloudwatchLog: '/aws/lambda/hello2'


2022-09-30 14:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.