使用 AWS API 网关 HTTP API 设置 Lambda 代理

Setting up a proxy to a Lambda using AWS API Gateway HTTP API

我想设置一个 Lambda 代理,以便所有子端点都由同一个 lambda 处理(这是一个 FastAPI 应用程序)。我已经使用 REST APIs 完成了这项工作,但我不知道如何使用 HTTP APIs.

我目前能够将特定端点路由到 lambda,并且按预期工作......但我想将 API 网关定义与每个服务定义分离(我们正在关注一种微服务方法)。 their docs 听起来好像只能将代理与另一个 HTTP 端点集成,但不是很清楚:

To set up a route with an HTTP proxy integration that catches all requests, create an API route with a greedy path variable (for example, /parent/{proxy+}). Integrate the route with an HTTP endpoint (for example, https://petstore-demo-endpoint.execute-api.com/petstore/{proxy}) on the ANY method

以前有人做过吗?可能吗?我更喜欢使用 HTTP APIs 而不是 REST APIs,因为它们更新、更快、更便宜。

视觉爱好者:

正在工作:

不工作:

Has anyone done this before? is it possible?

是的,我刚刚测试过,lambda 集成没有问题。对于我的示例,我使用了:

我想通了。我试图为我的代理重用现有的 Lambda 集成。删除集成并创建新集成后,一切都按预期工作。

我会删除这个问题,但如果以后有人遇到同样的问题,我会把它留在这里。