In this blog, I will be demonstrating you how to run Serverless Offline using a serverless plugin that emulates AWS λ and API Gateway on your local machine to speed up your development cycles. It helps us save time as we can see logs and also debug in our local machine rather than on cloud vendors.
Local environment reduces conflict with our team members who might be dependant on using the same function (even though in development) that you are working on and might get confused to why the function is not working whilst it was working before. You can make any changes and trials carefree as you will be the only one using this environment (unless you share it to the network) 😜.
This blog is for those who already know basics of Serverless Framework and its workarounds.
The Serverless Framework helps you build serverless apps with radically less overhead and cost. It provides a powerful, unified experience to develop, deploy, test, secure and monitor your serverless applications. — Serverless Framework
Steps:
Since you already know the basics of Serverless Framework, you must have installed the framework. Next, install the package serverless-offline from npm.
- Install package — serverless-offline
npm install serverless-offline --save-dev
- Add this installed plugin to your serverless project.
plugins:
- serverless-offline
- Run serverless offline using command:
> serverless offline
or
> sls offline
- You can see the list of available endpoints on http://localhost:3000/ and also use http://localhost:3000/ a base endpoint. Additional usage and command line options are available on the plugin’s official documentationpage.
Reference:
Top comments (2)
saved my day
abe basics to sabko pata hai, details kaha hai ?? :(