2

Need an expert's input who has used cloudformation, sam and serverless framework to deploy nodejs app.

Please advise which is the best path to take I have used serverless framework but not sam or cloudformation, while I agree that it simplifies the process, I wish to learn more on the underlying configuration.

I am leaning towards cloudformation just because both the frameworks transform the code to cloudformation templates. Please correct me if I am wrong and appreciate the best resources to learn the same.

Khuram Niaz
  • 881
  • 10
  • 16

3 Answers3

3

SAM is basically an extension of Cloudformation. If you know SAM, you basically know Cloudformation. SAM can and should be used in conjunction w/ Cloudformation for testing locally.

Serverless is an abstraction layer on top of Cloudformation. It helps to expedite app creation and deployment. It falls short if you are doing more advanced configurations

I always lean towards Cloudformation (or SAM) because it is provided by the CSP (ie AWS). This means everything new will be automatically available, rather than waiting for an abstraction layer (like serverless) to bake in support.

LostJon
  • 2,287
  • 11
  • 20
  • I would just caveat this with *usually* available immediately. I know there are some features that are available on the aws cli that are still not available through Cloudformation (ie. certain Cognito attributes) – Mikelax Nov 13 '19 at 19:04
2

I recommend the Serverless Framework. The advantages are several:

  • Much easier syntax than CloudFormation
  • More portable than CloudFormation (you can change between cloud providers)
  • Ability to write raw CloudFormation inline in serverless.yml if needed
  • Easy to deploy (just run sls deploy)

There is a sample project at my gitlab profile if you are interested (for GoLang but the principles are the same as for other runtimes) https://gitlab.com/montao/aws-lambda-go-gitlab-sls

Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
  • OP wishes to learn more about the underlying configuration, and is already familiar with the serverless framework. An abstraction layer somewhat obscures what goes on behind the scenes. – Dennis Oct 30 '19 at 19:51
2

LostJon is absolutely correct in that the support for both CloudFormation and SAM is immediately available as it is natively provided by AWS. I am leaning to CloudFormation for the reason that is has a deterministic outcome, which is desired in a DevOps landscape. There are no transformations unless you explicitly add transformations to your CloudFormation stack.

When you deploy a CloudFormation template with SAM, you will be able to view the CloudFormation template in the AWS console, but you can also choose to show the rendered template (e.g. after transformations) so that you can learn what SAM does for you underwater. You could copy the rendered resources and use them as pure CloudFormation. This allows you to speed up development, while not losing the benefit of knowledge of the underlying configuration.

Dennis
  • 779
  • 4
  • 14