Invoking Functions Locally
Execute Lambda function inside a container through PyCharm Professional.
In this tutorial we are going to run our lambda functions inside a local container.
We are going to use Docker. Docker is an open platform for developing, shipping, and running applications. Docker lets you separate your applications from your infrastructure, so you can deliver software quickly. If you are using Windows then you can use something called Docker Desktop.
Just follow the official documentation for the installation process, and you will be good to go.
PyCharm Professional is already running. I will click on Run then I will go to Edit Configurations.
Now, I need to choose Event Templates. I am going to pick a template called “Hello World”. This event is going to be passed into our Lambda function.
After that, I will click on SAM CLI, make sure to check “Build function inside a container”.
Apply and then
Then I will goto run and click on Run HelloWorld Function.
If you are running on Windows, then Docker Desktop will prompt for sharing the file. Kindly accept it.
As you can see, this is my JSON Response which I received from my lambda function. In the console you will be receiving more information like how much duration it took to execute the function along-with billed duration and max memory used.
This is how we can run and debug our lambda functions locally in our machine.