Skip to content
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

HTTP API support - API Gateway V2 #2099

Open
ryancausey opened this issue May 12, 2020 · 3 comments
Open

HTTP API support - API Gateway V2 #2099

ryancausey opened this issue May 12, 2020 · 3 comments

Comments

@ryancausey
Copy link

It looks like API Gateway has a new class of APIs called HTTP APIs which more closely fit with what Zappa aims to do. It might be good to start working on implementing support for this in Zappa.

https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html

The way Zappa deploys API gateways would have to be updated to also support this kind of API.

It also looks like there's a new 2.0 version of the event format sent to the lambda and the response format from lambda to the API gateway. This will have to be pinned to use the 1.0 formats until support for the 2.0 formats are added in the lambda handler provided by Zappa.

https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html

@nickovs
Copy link

nickovs commented Jun 2, 2020

Given that Amazon are touting 50% lower latency and 70% lower cost for the new version of the API, it would be great to see support for this.

@synap5e
Copy link

synap5e commented Aug 13, 2020

I modified Zappa to work for v2 for myself, although only for payload version 1.0. I'm unsure if Zappa would target using payload version 1.0 or 2.0. 1.0 would mean less code would be required for supporting both API GW v1 and v2.

The major changes required for the handler/wsgi code were

  • The stage/host handling is not correct (at least for $default stages). I simply removed https://github.com/Miserlou/Zappa/blob/master/zappa/handler.py#L502-L519, but correct logic for all cases (v1 with stage, test from console, v2 $default stage, v2 non-default stage) would need to be implemented.
  • Only multiValueHeaders should be provided in the response, even though headers and multiValueHeaders are provided in the payload. Currently this causes zappa to provide both headers and multiValueHeaders in the response, which causes duplicated headers in the http response.
    https://github.com/Miserlou/Zappa/blob/master/zappa/handler.py#L561-L568
    should be changed to only provide multiValueHeaders if provided with a multiValueHeaders payload. Looking at the spec now, it appears headers should also be provided (presumably empty if multiValueHeaders is used for all headers instead), but I didn't do this and it still works.

For my case I simply created a v2 gateway manually, but config and automatic creation of the api would of course be needed for proper support.

@dnnsthnnr
Copy link

There is a configuration setting payloadFormatVersion on AWS API GW integrations: https://docs.aws.amazon.com/apigatewayv2/latest/api-reference/apis-apiid-integrations.html

You can specify if the event should be in format of API GW v2.0 or in the format of API GW v1. So by using the you can create a v2 API GW but get a out of the box compatible format with zappa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants