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
Support for HTTP API #602
Comments
Hi, I completely agree with you. I have been using it as well in a side project and it's great. The blog article does mention a difference in the payload though (https://aws.amazon.com/fr/blogs/compute/building-better-apis-http-apis-now-generally-available/), I think we need to add some tests and review if there is any impact to Bref before adding it in the documentation. |
I didn't notice the payload change since serverless defaults to the 1.0 version ( Also not configurable to the 2.0 version yet (serverless/serverless#7477), so once that is possible it would make sense to implement. It also appears the response format may have to differ when using 2.0 format: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html#http-api-develop-integrations-lambda.proxy-format |
Oh that's interesting! So if I recap to make sure we are on the same page:
Do you know if the payload v2.0 applies also to the REST API? And if v1.0 is deprecated? |
My best guess is that 2.0 will not apply to REST API because of features that it has to support. HTTP API has less overall features and thus why it was able to have a simpler request / response format. |
Support for configuring payload 2.0 was merged: provider:
httpApi:
payload: '2.0' |
FYI this still errors: provider:
httpApi:
payload: 2.0 adding single quotes around '2.0' makes it work. The guide/cheat sheet https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/ shows without quotes |
Thank you @larswww, I have opened serverless/serverless#7772 to improve the documentation in Serverless. |
With traditional REST API calls, bref passes context through in
I've tried explicitly setting payload for both 1.0 and 2.0 but neither one provides these missing values. Is there anywhere I can get them from? |
Found the solution: use an explicit layer arn and payload 1.0. provider:
httpApi:
payload: '1.0'
functions:
api:
handler: public/index.php
description: ''
layers:
- arn:aws:lambda:ap-southeast-2:209497400698:layer:php-74-fpm:7 Leaving this here in case someone else runs into the same problem.
|
@geoff-ellison This doesn't seem correct. Is it possible there is an issue with the original layer version you were using? Explicitly listing the layer vs using the plugin syntax I'm using this layer functions:
api:
handler: public/index.php
timeout: 28
layers:
- ${bref:layer.php-74-fpm}
events:
- httpApi:
path: '*'
|
Full support with the v2 payload format has been added in #604, I will tag a new release. |
Thanks @aknosis but the problem was the combination of the layer together with cognito-based authentication. The only circumstance where everything worked was an explicit bref layer together with payload v1. And then suddenly, I could use the latest (
The seemingly random outcomes now all make sense. The timing of 3 June fits exactly. So now when I get a chance I will attempt with payload v2 (and latest php 7.4 bref) and see what happens. |
HTTP APIs are now generally available: https://aws.amazon.com/blogs/compute/building-better-apis-http-apis-now-generally-available/
I think we should implement HTTP APIs as an option during initialization and eventually migrate toward making them the default.
Reasons to migrate to HTTP APIs:
Faster
Cheaper
$default Stage
HTTP APIs allow for a $default stage, this stage will point to the root domain (e.g. https://abc123.execute-api.us-east-2.amazonaws.com), this gets rid of all the issues relating to the state prefix.
The changes required are very simple (assuming default serverless.yml setup).
REST API:
HTTP API:
Anecdotally, I have been running a bref app on an HTTP API for about a month now with no issues.
The text was updated successfully, but these errors were encountered: