Reputation: 1237
New to AWS and found it quite straightforward so far but really getting stuck packaging a lambda function.
I'm using node-lambda to try and run the function but keep getting the following error on node-lambda run:
/usr/local/lib/node_modules/node-lambda/lib/main.js:93
handler(event, context, callback);
^
TypeError: handler is not a function
at Lambda._runHandler (/usr/local/lib/node_modules/node-lambda/lib/main.js:93:7)
at Lambda.run (/usr/local/lib/node_modules/node-lambda/lib/main.js:49:8)
at Command.<anonymous> (/usr/local/lib/node_modules/node-lambda/bin/node-lambda:89:12)
at Command.listener (/usr/local/lib/node_modules/node-lambda/node_modules/commander/index.js:301:8)
My index.js file has the handler declared like so
exports.myHandler = function(event, context) {
And the AWS_HANDLER in my .env is set to index.handler. I eel like I'm missing an obvious step.
Upvotes: 13
Views: 14697
Reputation: 231
use exports.handler = async function(event, context) {
instead of
exports.myHandler = function(event, context) {
Upvotes: 2