New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
SAM vs Serverless: switch to Serverless again? #320
Comments
Hey @mnapoli, I will always favor Serverless Framework because it's one less vendor lock we have. I will have a look in local dev with custom layer the next few days and will let you know if I get anywhere. With python I know it works great. |
Ok, some updates. Definitely Possible to run bref locally with SLS. The test: the YML:
Install serverless-offline (npm install serverless-offline --save-dev). In Serverless offline need to edit 2 files, index.js
functionHelper.js - (need to add --docker if it is provided) line 16: That's it. on console, execute it will start a Webserver in port 3000. Every call he builds the layer and execute. Of course we need to Edit some things in serverless-offline and make a PR, but we can Definitely run it. You can edit in the Google Sheets :) |
I would ask not to rewrite (a.k.a remove) the SAM documentation. If you decide to change, I understand switching the entire focus of the docs, but keep the bare minimum (layer arn) documented. I would personally stick with CloudFormation since that's where everything else is deployed and the vendor lock-in argument doesn't work at all for my company since we make heavy use of AWS-only services. Having AWS structure declared in the SLS framework means leaked abstraction which means vendor lock in anyway. I forgot to mention that one strong reason for me to not switch to SLS is because my pipeline has no js dependency at all. All I need is AWS CLI and an authorized Role, which is convenient. Things that are not a problem if you're using CodePipeline (from the spreadsheet): Define the region once and for all |
@atrope thanks that sounds really cool, I'll have a look at it. And yes if it's a matter of a quick fix in the plugin I'm sure this is something we can sort out over time. @deleugpn good points. Just to be clear I still plan on targeting AWS only for now. But yes since layers work with SAM or Serverless or any other tool, people can still use Bref tooling with whatever they prefer 馃憤 The switch to serverless would be mostly useful for those starting and those looking for an all-in-one solution with complete documentation. |
Just dumping the link here: https://www.jeremydaly.com/developing-serverless-applications-locally-with-the-serverless-cloudside-plugin/
It's compatible with serverless-offline as well. That's another advantage for serverless here ^^ |
Gotta be extra careful with that one. Imagine pushing local development messages to a Queue and having your deployed worker inside AWS picking those up and trashing your staging / live database. |
Localstack looks really interesting! There are so many things to try out 馃槄 But it's great! |
FWiW, I'm in favour of serverless. |
I would also ask not to remove CloudFormation docs. This will be a huge breaking change. I personally use BREF in my job and we have a setup our "infrastructure as code". Using AWS with BREF, CloudFormation template can be imported in other stacks, and can import stacks as well. IMO best case will be to choose what to use during setup time - Serverless or CloudFormation, and then a template will be generated based on your choice. This way changes you plan to introduce will be backwards compatible. But please don't remove support for CloudFormation as it will break a lot of production apps that currently opted to use Bref and relying on CloudFormation. |
@Sh1d0w supporting 2 deployment config (both in the code and documentation) would be too much effort at the moment. One of Bref's principle is this:
We should support one format perfectly instead of spreading our effort and making it more confusing for users.
Rest assured however that anything you wrote will still work. Also you will still be able to use SAM if you want for new projects. For example right now I use serverless for some projects even though Bref recommends SAM. The PHP layer works with both solutions. Nothing should break. Also I want to reassure you that serverless configuration supports CloudFormation syntax. There are a few specific bits that a different but anything you do with SAM can be done with serverless. But if you don't want to change that's fine, it will still work. |
By reading the documentation, I felt like SAM is not completely local. There is some communication taking place with AWS Cloud although the function itself runs locally. |
I support switching to serverless. And I agree that we can't maintain both. Serverless it is! |
For those interested there is a WIP in this branch: https://github.com/mnapoli/bref/tree/serverless |
Wow! @mnapoli ! Thank you for the heads up! Can't wait for it to be released. Currently I need to deploy my lambda to multiple regions and doing with sam is a pain. |
Nice! You can start using Serverless right now, I've been using it for some projects. It's already compatible. |
@mnapoli You made my day! That's really great news! Yay! |
@mnapoli A question on serverless plugin usage. Is it supposed I need to copy bref.js to my project .serverless_plugins/ ? |
That is experimental, you can ignore all this and keep using the layer ARN explicitly. |
But how can I do it if I need to deploy it to multiple regions? I guess I want to run:
but if I have the layer ARN specified explicitly it will not work. I was thinking maybe I could modify the plugin to make some sort of switch there and specify ARN for each region? |
You can use region variables (see https://serverless.com/framework/docs/providers/aws/guide/variables/) but I'm sorry I can't document everything in this issue. My first priority is to keep the same set of features. Right now you can't deploy easily to multiple regions with SAM and Bref. |
Yeah, it works like this:
awesome! thank you @mnapoli for all your work on bref! can I help you with anything to make it better? |
I confirm that @atrope's PR makes it possible to run API Gateway + Lambda locally with Serverless (it works through Docker): dherault/serverless-offline#648 This isn't as fast as it could be (a bit like SAM, the lambda starts from scratch every time) but it can be optimized over time. We need dherault/serverless-offline#648 to be merged (or the worst case would be to fork the plugin to apply the change, but that's way more work). |
Hi @mnapoli as i said, i think some work could be done in the future so the docker container would be reutilized instead of initializing from scratch all the time. I updated the code from master in the PR and fixed what needed to be fixed now we must wait and see if they will approve it. |
Yes let's discuss switching back again from SAM to the serverless framework (documentation) 馃槃 (see #99)
I open this issue because things have moved forward with the serverless framework. Mainly: it supports layers and it can run things locally with Docker.
But another big reason is that, after trying again serverless, it solves a lot of small pain points with SAM. For example:
and it is extensible. That opens very interesting doors, for example to simplify a lot some things like setting layer ARNs:
After with serverless:
What's great with that as well is that runtime versions could be handled by Bref itself, making upgrading Bref as simple as
composer update
.In short serverless could help make things simpler.
BC break
If we switch we would direct tooling efforts towards serverless.
However Bref would still work with SAM.
But since the documentation would be rewritten to target serverless I think it could be considered a BC break (or a major change).
Full comparison SAM vs Serverless
Here is a complete comparison of features:
https://docs.google.com/spreadsheets/d/1DP2uVbg6TLfBa56XJ1GwlSSKQM1sM87-S3LQ2Pl9sPI/edit?usp=sharing
Please have a look and comment (here or in Google Docs) what is missing and what should be added to the list.
As you will see Serverless has a lot of advantages, the only big question left is local development.
WDYT?
The text was updated successfully, but these errors were encountered: