-
-
Notifications
You must be signed in to change notification settings - Fork 366
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace API Gateway with CloudFront + Lambda Function URLs everywhere in Bref? #1625
Comments
A couple of questions:
|
@shadowhand regarding question 1, I listed it in the "Cons" (but edited early today, so you might have missed it):
To expand on the first option, here are more info: https://stackoverflow.com/a/72271684/245552 I'm not sure if that should be a native Bref feature 🤔 Deploying lambda@edge would for sure not be, because it's complex and it sucks. But maybe the header thing…
Existing users wouldn't be impacted. Their serverless.yml wouldn't change. Only the Bref docs would change, but the main difference is about replacing The |
I only recently learned about function URLs myself (because they also allow streaming responses - which is great for AI-powered applications!). However three questions came up:
|
Very good points! 1. Does the current setup always link to $LATEST or does it handle switching to the new version internally? Sometimes things can go wrong and you have to go back a version I'm not sure it could do what you may want. Here are what the docs say:
You could use aliases, but I don't think the Serverless Framework does anything clever. But you may achieve that yourself? Given most Bref users don't use Lambda versions at all, that's not something I intend to support for getting started templates/docs. Users can grow into these features by themselves if they want this, Bref is compatible with whatever Lambda can do. 2. Would rate-limiting be done via CloudFront in this case? Even if lambda can support millions of requests, I don't need to have more than 5k requests/sec for most smaller apps. Good point, here are the Lambda docs:
It seems you can easily limit the RPS, so it seems to do the job, right? (at least as good as API Gateway?) 3. Api Gateway also offers a firewall, does AWS WAF work the same when it's just CloudFront? WAF works with CloudFront (and it's even better because AWS Shield Advanced only supports CloudFront, not API Gateway). |
Also on API gateway v1, I think. Though v1 does not have great performance or pricing. |
I'm interested in this because ApiGatewayV2 is not supported in eu-south-2 (Spain) region. |
@kevincerro the main thing we need to have is make https://github.com/getlift/lift/blob/master/docs/server-side-website.md use Function URL if API Gateway is not used (it requires code changes in Lift). For the documentation I can take care of that 👍 (but it's currently blocked by the Lift issue). |
I'm going to try to take care of this |
Draft PR here, some improvements are needed regarding configuration logic |
function urls is not supported either. |
Yes I know, I hope that AWS will add lambda url to eu-south-2 soon. |
I know there hasn't been progress here. I'm posting two updates in favor of using FURL over API Gateway v2:
|
Right now, Bref's docs/examples/defaults deploy:
For websites, it deploys:
Lambda Function URLs are great to replace API Gateway. However they don't have custom domains. That means you need CloudFront (for the custom domain). That works for websites right now (we already have CloudFront there), but not APIs (which don't use CloudFront).
How about dropping API Gateway entirely (for the docs/examples, Bref would still work with it of course) and go full Lambda Function URLs + CloudFront.
We would have 3 different scenarios:
That would be super cheap for testing and deploying preview URLs.
Same as today, no changes except API Gateway is removed.
Pros:
serverless.yml
configCons:
I did rough calculations and it seems that it could be actually cheaper for 99% of use cases! CloudFront has a much bigger free tier (10 million HTTP requests, compared to 1 million for API Gateway). Beyond that, it seems to be about the same price, but even at this scale it can be optimized on a case by case basis.
Summary:
Running APIs and websites might be simpler, faster and cheaper!
Am I missing anything? Feedback is welcome 🙏
The text was updated successfully, but these errors were encountered: