DEV Community

Let's Do Tech
Let's Do Tech

Posted on • Originally published at blog.letsdote.ch on

Ways To Iteratively Develop Lambda Functions

minimalist photography of three crank phones

Photo by Pavan Trikutam on Unsplash

Thanks for sending in all those B-Day wishes. I had some travel plans due to the same occasion and that also explains the delay in sending out this email update.

The last week was a short one - work wise. During my travel, I contemplated about the serverless things I did right, and also the wrong ones in this month. One aspect of serverless development I want to make better is the iterative development process.

What have I used till now?

To develop and deploy the Lambda functions alone, you don’t need much - as far as you are just trying out with something like NodeJS - where the code editor is supported. In case of Golang you have to develop the code locally, build it, and then upload the binary to the Lambda function.

Building the binary is indeed an additional step in developing Lambda functions with Go - some even frown upon - but it is also a performance booster.

Performance matters in the world of pay-per-use. A 10x improvement in performance roughly means the same extent of reduction in cloud spend.

To have a defined development cycle, for the last couple of months I have used Terraform and Amplify mainly to create and deploy Lambda functions, and a couple of days back I tried AWS SAM (Serverless Application Model) to have the taste of managing Lambda functions.

  1. Terraform - I created my own boilerplate IaC to take the Go source code and build a lambda function out of it. This is by far my favourite way to manage lambda functions till now. It might not be the easiest, but I do plan to manage almost all components in all environments using Terraform - so doing the Lambda functions as well make a lot of sense.

  2. Amplify - I was in search of an easy frontend development and hosting solution. Amplify fits the bill perfectly for the same, but it also creates certain backend components to support the frontend - like Appsync, DynamoDB, Lambda functions, API Gateways. Initially I tried to make peace with Amplify, but later it became difficult to draw a line of management between the backend components created by Amplify and the ones created by Terraform.

  3. SAM - the tool I have least experience on, but still found it to be of great use considering its local testing feature. Out of all the approaches I have tried so far, the local testing function offered by SAM is great.

Why didn’t I use serverless framework or Cloud Formation Templates?

You can call me a fanboy if that is what they say, but I have spent quite some time with Terraform and I am very comfortable with it. Learning parallel technologies is not the best use of time.

I wanted to try the serverless framework out of FOMO, and did go through the documentation. It is a great solution. But for me personally, it would have been either this or that (Terraform). For all my IaC needs, Terraform fits the bill, but I was not sure about this in case of the serverless framework. I am still unsure if the serverless framework is used to create just the functions or other cloud resources as well?

The story is similar for CloudFormation templates. Additionally, it being AWS specific discouraged me even more.

One may point out Amplify uses CloudFormation Templates under the hood. That is exactly what I want - as far as it is being used under the hood and I still get to manage the resources I intend to, I am good. There is no enemity with any tool, I promise. 😂

So, the plan.

I might want to explore other solutions given the limitations of currently chosen ones (if I find them), and I will do so if required. But for now, this is the plan.

For the long term and scaled IaC requirement for Lambda functions (and other cloud resources as well!), I plan to use Terraform.

I still use Amplify for frontend solution, but with a rule of not creating ANY backend components via the same. Amplify is strictly used for managing React components and occassional integration with Figma. All the backend components like Lambda functions, DynamoDB, API Gateway - required by the frontend - will be managed via Terraform.

For the local development or trying out PoCs, I plan to use SAM since it allows for local execution and quick testing. I am not well versed with it but will soon be.

Your thoughts

I am keen to listen to your thoughts. Would there be a better way to achieve quicker interations for Serverless development?

Sumeet N.

Top comments (0)