DEV Community

Serverless on AWS Lambda: A Comprehensive Comparison Of Approaches (Serverless Framework vs SAM vs Terraform vs CloudFormation)

Lou (🚀 Open Up The Cloud ☁️) on April 01, 2020

When it comes to working with Serverless and AWS Lambda there are many different tools and approaches to choose from. You may have heard about a fe...
Collapse
 
rolfstreefkerk profile image
Rolf Streefkerk

Fair assessment and it's very much the same with my experience. I haven't tried SAM, but I know some Cloudformation so it's not too far off.
I went full Terraform because I found Serverless to be too much of an abstraction from whats going on and it would very quickly require me to use another tool set to deploy Elasticsearch, EC2 or RDS. That's just a pain to me.

Downsides with Terraform are its slow development time for some resources, particularly support for Websockets is still not fully developed with its release by AWS already more than a year ago.

It's also quite verbose if you do not use modules how they should be used and the initial learning curve as you mentioned can be quite steep.

For me it's been worth using Terraform since I want to know whats going on under the hood, if you're not too bothered or are more pragmatic about it Serverless can boost productivity quite a bit.

Collapse
 
loujaybee profile image
Lou (🚀 Open Up The Cloud ☁️)

Glad to hear you thought it was fair! I was trying my hardest to bite my lip to keep it unbiased! In some parts I'm more replaying some thoughts that I've heard from around the community rather than my own opinion.

My personal preference is the same, to just use Terraform (I'm very sure I'm in the minority here). That's probably because I'm comfortable with Terraform and happy to provision my own resources, I'd rather be reading the AWS docs than serverless framework docs, personally.

I see serverless framework very similar to Heroku. Great if you have a low level of infrastructure chops, but then you might start to feel restricted. From a personal perspective I found that after using Serverless framework I got immediately frustrated when I couldn't just look at the AWS resource and directly change my resources. I guess if you're a total beginner this would be frustrating / daunting so it's totally cool if you're new to the tech.

And then of course come the "but what about local dev?", etc, arguments... But I've found that if the app is well setup you can just use a container (or similar) to run it locally (and actually IMO this is an anti-pattern). Well mocked tests go a hell of a long way (and serverless framework isn't going to do the hard work of setting you up a well tested app with well written mocks).

Come to think of it, there's clearly a whole different article in there about: "Here's the frameworks and things you can do... but here's what I actually do" 😂

Collapse
 
rolfstreefkerk profile image
Rolf Streefkerk

Local development is a whole other discussion, but as you said I also consider it to be an anti-pattern for the simple reason environments are never the same. I never bother running local tests for that simple reason to avoid issues that are very hard to debug

Collapse
 
elthrasher profile image
Matt Morgan

Some good info here. Of course if we're just talking about deploying lambdas, you've left off console and cli. 😜

I'm using SAM and have had good results getting developers to learn and understand how to use it. SAM isn't actually an abstraction of CloudFormation like Serverless, but an extension. Valid CloudFormation can be used in a SAM template.

I'm also modeling some new infrastructure using CDK. Whether anything goes to production that way remains to be seen. At the very least, CDK is a quick way to write some IoC and you can always just grab the CF template and use that. Of course like terraform and CloudFormation, it lacks any local execution. But still, I expect to see it start showing up on these lists.

Collapse
 
mkunikow profile image
Michal Kunikowski

can you add also info about :
aws.amazon.com/cdk/
pulumi.com/

Collapse
 
loujaybee profile image
Lou (🚀 Open Up The Cloud ☁️)

Thanks for the suggestions! I'll take a look and make some updates for people to go check them out!

Collapse
 
mkunikow profile image
Michal Kunikowski

You can check this awesome video
Programming the Cloud: Empowering Developers to Do Infrastructure
youtube.com/watch?v=yIIMf8ohrsg

Thread Thread
 
loujaybee profile image
Lou (🚀 Open Up The Cloud ☁️)

Thanks Michal! It's on the to-watch list!

Collapse
 
davidalvez profile image
David Alvez Amarillo

There are 2 big players missing here : Ansible and CDK.
docs.ansible.com/ansible/latest/mo...

Collapse
 
loujaybee profile image
Lou (🚀 Open Up The Cloud ☁️)

Thanks for the suggestion! I'll take a look and make some updates for people to go check them out!