We are working on project, we are tring to build serverless application in nodejs. I come terms across AWS SAM and Serverless. Which is best for implementing serverless application
SAM is the Serverless Application Model. It's an AWS abstraction over AWS CloudFormation that makes common serverless architectures easier to define. The Serverless Framework is an open-source project maintained by Serverless that not only makes it easier to define but also deploy serverless.
AWS SAM is another framework similar to Serverless Framework that it let's the developer write less code when building serverless applications. Unlike Serverless Framework, SAM is specific to AWS and its main configuration file template.
The AWS Serverless Application Model (AWS SAM) is an open-source framework for building serverless applications. It provides shorthand syntax to express functions, APIs, databases, and event source mappings. With just a few lines per resource, you can define the application you want and model it using YAML.
Conceptually there is no difference between a serverless or a Lambda function. Serverless is the generic term for what AWS calls Lambda (and API Gateway). The serverless framework is then just a software project that builds upon serverless principles, and that can work with AWS Lambda (amongst others).
You can check this article comparing SAM and Serverless
The key differences listed on that page are as follows
The Serverless Framework is a framework that makes it easy to write event-driven functions for a myriad of providers, including AWS, Google Cloud, Kubeless and more. For each provider, a series of events can be configured to invoke the function. The framework is open source and receives updates regularly.
The AWS Serverless Application Model (SAM) is an abstraction layer in front of CloudFormation that makes it easy to write serverless applications in AWS. There is support for three different resource types: Lambda, DynamoDB and API Gateway. Using SAM Local, Lambda and API Gateway can be run locally through the use of Docker containers.
Both frameworks have in common that they generate CloudFormation. In other words: they both abstract CloudFormation so that you need to write less code to build serverless applications (in the case of SAM) and to deploy Lambda functions (for both SAM and Serverless). The biggest difference is that Serverless is written to deploy FaaS (Function as a Service) functions to different providers. SAM on the other hand is an abstraction layer specifically for AWS using not only FaaS but also DynamoDB for storage and API Gateway for creating a serverless HTTP endpoint.
Another difference is that SAM Local allows you to run Lambda functions locally and to spin up an API Gateway locally. This makes it easier to develop and test Lambda functions without deploying them to AWS. With the Serverless framework you can also invoke Lambda functions from the command line, but only if they are deployed to AWS and available through API Gateway.
Biggest differences between SAM and SF:
1) SAM is AWS only; SF supports multiple backends so it supports deployment for multi/hybrid cloud application. SF also support kubernetes backend.
2) For AWS, both SAM and SF templates compile to Cloudformation (CF). SAM has the ability to use Transform which is essentially macros for CF.
3) SAM is written in Python; SF is written in Javascript.
4) SF has plugins which allow you to run any codes (including non-Javascript); which effectively means it's possible to go beyond limitation of Cloudformation (CF) since there are always something (new-ish) that isn't supported in CF yet. Plugin system is also extremely flexible and can be very useful.
5) SF variables system is more flexible which allow you to do dynamic include based on existence of other parameters (such as stage); SAM variables are much closer to CF.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With