AWS Lambda is one of the exciting services provided by Amazon. It provides us with a UI where we can type our code and deploy it instantly without any need for a server. In this article, let us see the things to keep in mind if you develop the code using lambda console.
If you are someone new to AWS Lambda, check out this blog.
Note: You can also write the lambda code locally in your machine and upload using serverless, terraform.
Save Before Deploying
There were numerous occasions where I use to type the code and click deploy immediately. When I click on “Test” to execute the code I mostly get invalid syntax or not found error. When I check the logs I can find that 2 or 3 characters that I typed before clicking on deploy would have not saved. So from then, I got into the practice of saving before deploying.
As of today there is no save button in the console but you can give “ctrl + s” to save the code. You will also be indicated by a small green light next to the file name.
Be Aware of event selection before testing
Make sure you are passing the appropriate event before clicking on the “Test” button. I personally use to save many test events. So whenever I update any other event I was under the impression that it will be the event that will be used to execute next when I click “Test”. But the event that will be selected to execute will be a previously selected event. So make sure you click the dropdown next to the “Test” button and select the event before executing.
Cannot stop lambda instance until timeout
The lambda timeout is something that will make you feel helpless in case you have a long timeout period (maximum 15 minutes) and you need to stop the code in the middle of execution. So as a best practice have a very little timeout period during the initial stage of development.
Happy programming!!
Thank you for the cool content. Keep up the good job, Ranjith!
Thank you Bing