I'm trying to find out how can I use Visual Studio Code debugger to debug serverless lambda function. For testing purposes I have very simple test
lambda function:
module.exports.handler = async (event) => {
debugger;
console.log(111, event);
};
Then, in launch.json
I created such a configuration:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeVersion": "8.4.0",
"runtimeExecutable": "node",
"program": "${workspaceFolder}/node_modules/.bin/sls",
"cwd": "${workspaceRoot}",
"args": [
"invoke",
"local",
"--function",
"test",
"--data",
"{foo:'bar'}"
],
"port": 9229
}
]
}
Now, I'm puting a breakpoint inside my lambda function and pressing F5 to start debugger. I'm expecting then to go in code, put some watches and walk my code step-by-step. But nothing happens. No errors. No console outputs, no code paused on breakpoints. Nothing. All I get is message in debug console
: /home/set/.nvm/versions/node/v8.4.0/bin/node node_modules/.bin/sls invoke local --function test --data {foo:'bar'}
If I go then in terminal and run that line I got exactly what is expected
set@set-home ~/www/blahblah/ens $ /home/set/.nvm/versions/node/v8.4.0/bin/node node_modules/.bin/sls invoke local --function test --data {foo:'bar'}
Serverless: INVOKING INVOKE
111 '{foo:bar}'
What am I doing wrong? How can I debug serverless application in Visual Studio Code?