I'm trying to run locally a node lambda to debug it. I am using Serverless and this launch config in vsCode
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/node_modules/.bin/sls",
"args": [
"invoke",
"local",
"--function",
"hello",
"--data",
"hello world"
]
}
]
}
My export.handler looks like this:
module.exports.handler = (event, context, callback) => {
if (event.triggerSource === CONSTANTS.TRIGGER_SOURCE) {
console.log("event = " + JSON.stringify(event));
const uri = process.env.SCT_URL_BASE;
const country = process.env.SCT_COUNTRY;
const username =
event.request.userAttributes[CONSTANTS.USER_ATTRIBUTES];
const codeP = event.request.codeParameter;
console.log("URI = " + url);
console.log("Code:" + codeP);
getUrlData(uri, country, username, codeP);
} else {
context.done(null, event);
}
};
When I run de debug mode it does nothing. Serverless does not throw any error, I just can not reach inside the function.
Also, there is another thing I can not understand. In serverless documentation it said:
--function or -f The name of the function in your service that you want to invoke locally. Required.
I don't know what they are refering in this, if a function that we call to run the lambda or the function that it is called when the lambda is called. In this case, the function that I am exporting is "handler" but it doesn't work either.
Thanks in advance.