1
votes

I want to set up a proxy to a Lambda so that all sub-endpoints get handled by the same lambda (it's a FastAPI app). I've got this working using REST APIs but I can't figure out how to do it with HTTP APIs.

I'm currently able to route specific endpoints to the lambda, and that works as expected... but I'd like to decouple the API Gateway definition from each service definition (we're following a microservices approach). From their docs it kind of sounds like you can only integrate a proxy with another HTTP endpoint, but it's not exactly clear:

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

Has anyone done this before? is it possible? I'd prefer to use HTTP APIs over REST APIs since they're newer, faster, and cheaper.

For the visual folk:

WORKING:

  • REST API:
    • /test/{proxy+} -> app_lambda
  • HTTP API:
    • /test/endpoint1 -> app_lambda
    • /test/endpoint2 -> app_lambda

NOT WORKING:

  • HTTP API:
    • /test/{proxy+} -> app_lambda
2

2 Answers

1
votes

Has anyone done this before? is it possible?

Yes, I've just tested it, and there no issues with lambda integration. For my example I used:

enter image description here

0
votes

I figured out the problem. I was trying to reuse an existing Lambda integration for my proxy. After deleting the integration and creating a new one everything worked as expected.

I'd delete the question, but in case someone runs into the same issue in the future I'm leaving it here.