Rapidly previewing the effect of code changes is essential to any software engineering process. But when developing on AWS using the Serverless framework, it can become a challenge, because every sls deploy can take more than tens of seconds.

Besides replicating the entire AWS stack on our local machine, there are two achievable ways to speed up the feedback loop.

Deploy only the changed function

sls deploy deploys the entire stack specified in serverless.yml, including the databases, gateway, SQS, etc. This can be very time-consuming.

Thus, if all that we’re modifying are codes in a particular Lambda function, then it makes timely economic sense to deploy just that one changed Lambda function:

sls deploy function --stage mystage --aws-profile myprofile -f myFuncName

View the real-time log

console.log() is one of our best allies in debugging and troubleshooting codes. But having to refresh and catch new logs in the AWS web console may not be the most productive.

Thankfully there’s a way to tail the logs directly on our local machine:

serverless logs --stage mystage --aws-profile -f myFuncName -t

Source of info: https://www.serverless.com/blog/quick-tips-for-faster-serverless-development

Leave a comment