One problem that was often seen as the inability to run and debug functionalities locally. The Visual Studio (VS) Code and the Serverless framework are required for debugging the AWS Lambda using Node.js. There is an SDK available for Python and Java as well.
The Serverless framework has a feature to invoke the local command. This emulates the AWS Lambda environment though maybe there could be some minor errors which will not have much impact.
serverless invoke local –function functionName
Two wire protocols exist:
You now can locally run and debug your Lambda functions.
Deploy the Serverless framework as devDependency
There are many advantages of using the Serverless framework as a dependency in a project since
Enable the debug configuration
Invoke the “sls invoke local” CLI command serverless invoke local –function functionName
Or the local function invocation can be done with custom context.
serverless invoke local –function functionName –context “hello world”
You may also invoke the local function with data passing like in a JSON file.
serverless invoke local –function functionName –contextPath lib/context.json
Click on the green triangle icon in the Debug view on the VS Code. This may also be done using your keyboard functions of Ctrl + Shift+ D. Debug View will show all the relevant information about debugging with a set of commands and configuration settings on the top of the screen.
The debugging configuration information in a launch.json file is stored by the VS Code in a .vscode folder in the project root folder or in the user settings. To start the debugging session, select Launch Program using the configuration drop-down menu or you could also use Command Palette using the filter on Debug (Select start debugging). The Debug Console status bar will turn Orange.
The toolbar will show at the top of the editor will display signs like Continue/Pause, Step-over, Step-into, Step-Out, Restart or Stop etc. for you to drag the function you want. The session will stop automatically once the debug program is over.
Avail the free AWS Cloud demo before your final purchase. Call our experts 1800-212-2022/1888-288-3570.