mirror of
https://github.com/serverless/serverless.git
synced 2026-02-01 16:07:28 +00:00
2.0 KiB
2.0 KiB
ss
Read this on the main serverless docs site
CloudWatch Log
Current gotchas
We have one problem on this event.
If you replace the same logGroup name with another function statement in serverless.yml and run sls deploy, the deployment will fail with an error.
We will fix it in an upcoming release, please be careful of this note when using this event.
Here's step to reproduce.
First, write serverless.yml as follow and run sls deply.
functions:
hello1:
handler: handler.hello1
events:
- cloudwatchLog: '/aws/lambda/hello1'
hello2:
handler: handler.hello2
events:
- cloudwatchLog: '/aws/lambda/hello2'
Next, edit serverless.yml(replace logGroup name) as follow and run sls deploy again, then the deployment would fail.
functions:
hello1:
handler: handler.hello1
events:
- cloudwatchLog: '/aws/lambda/hello2'
hello2:
handler: handler.hello2
events:
- cloudwatchLog: '/aws/lambda/hello1'
Simple event definition
This will enable your Lambda function to be called by an Log Stream.
functions:
myCloudWatchLog:
handler: myCloudWatchLog.handler
events:
- cloudwatchLog: '/aws/lambda/hello'
Specifying a filter
Here's an example how you can specify a filter rule.
For more information about the filter pattern syntax, see Filter and Pattern Syntax
functions:
myCloudWatchLog:
handler: myCloudWatchLog.handler
events:
- cloudwatchLog:
logGroup: '/aws/lambda/hello'
filter: '{$.userIdentity.type = Root}'