TypeError: event.cloudwatchLog.logGroup.replace is not a function
See original GitHub issueThis is a (Bug Report Proposal)
Description
For bug reports:
- What went wrong?
Get the error when reference a log group.
TypeError: event.cloudwatchLog.logGroup.replace is not a function
- What did you expect should have happened?
replace the reference log group name with real one.
- What was the config you used?
functions:
pushCustomAccesslogs:
handler: logs/logs.handler
events:
- cloudwatchLog:
logGroup: { "Ref": "CustomAccessLogs" }
resources:
Resources:
CustomAccessLogs:
Type: AWS::Logs::LogGroup
- What stacktrace or error message from your provider did you see?
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Packaging service...
Serverless: Excluding development dependencies...
LogGroupName: { Ref: 'CustomAccessLogs' } # <=== Here is the name
Type Error ---------------------------------------------
event.cloudwatchLog.logGroup.replace is not a function
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Stack Trace --------------------------------------------
TypeError: event.cloudwatchLog.logGroup.replace is not a function
at functionObj.events.forEach.event (/usr/lib/node_modules/serverless/lib/plugins/aws/package/compile/events/cloudWatchLog/index.js:48:59)
The error line is:
LogGroupName = event.cloudwatchLog.logGroup.replace(/\r?\n/g, '');
Additional Data
Your Environment Information ----------------------------- OS: linux Node Version: 6.11.3 Serverless Version: 1.25.0
I added a debug line before replace function:
console.log("LogGroupName: " , event.cloudwatchLog.logGroup);
from deploy debug log, seems the logGroup name is not referenced properly:
LogGroupName: { Ref: 'CustomAccessLogs' }
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Is it possible to log whenever certain api's are called
Set a Cloudwatch log group and enable events in a lambda function to ... TypeError: event.cloudwatchLog.logGroup.replace is not a function.
Read more >serverless/serverless - Gitter
I have this serverless example that sends logs (from /aws/lambda/somelogs loggroup) to a lambda. But now I want to send the cloudwatch logs...
Read more >How do I fix "Log group does not exist" errors for Lambda ...
How do I fix " Log group does not exist" errors for Lambda function logs in the CloudWatch console?
Read more >Top 10 Serverless Deployment Errors (and How to Fix Them)
config file in your function directory. 7. CloudFormation cannot update a stack with custom-named resource request. The error: Failed To Deploy ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m closing as it’s not really a bug. It’s just we do not support CF intrinsic functions at
logGroup
property, as to properly handle the event we need to have log group name resolved.This issue was kept open initially as we didn’t have proper error reporting in place, but now that’s solved with configuration validation backed by schema, and schema clearly indicates we accept an only plain string as an input.
If you feel we can maintain the same functionality while extending the support for CF intrinsic functions at
logGroup
property, please open a new feature request, detailing the idea. If it’ll promise desired results we will definitely welcome the PR.Running in this issue too, whereby we are deploying into multiple accounts and want to dynamically replace the region and account