1

I've been setting up an HTTP gateway for the first time and came across an issue with private integrations. I want all my integrations to be private but it doesn't work well with routing.

I have a private integration with a $default route and it works great. Now I want another private integration to be mounted under, say, /microservice/ and have all its endpoints proxied.

This however seems impossible because private integrations ask you for a backend ARN rather than URI, so there's no way to use path variables like {proxy+}. This results in only root of my microservice being accessible through the gateway - all the other paths just go to the $default route.

How would one go about setting up a private integration like this? Ideally I would like something like this:

- /microservice1/{proxy+}
- /microservice2/{proxy+}
- $default

Currently as I understand it I only have two options:

  • Expose my services to the world and use public integration with greedy path variables {proxy+} - not ideal
  • Keep the private integration but define each microservice endpoint as it's own route on the gateway - extremely annoying to maintain

Is there a good way to do this that I'm missing?

1 Answers1

2

To answer my own question - this is possible with request parameter mapping that transforms request before it reaches the backend:

  1. Create a route with greedy path variable: /microservice/${proxy}
  2. In your private integration create a path mapping: overwrite:path = /$request.path.proxy
  • @dmitrybelyajov, do you know how to implement path rewrite like this: api.example.com/v1/app1/user/add => https://app1.example.com/user/add I.e. without "/v1/app1" part. https://repost.aws/questions/QU8_a_LKzJT86VCIV4-J3cpA/api-http-gateway-path-rewrite-question – Vitaly Karasik DevOps Jun 30 '22 at 10:13