3

I'm trying to do some vary basic routing with API Gateway. I need to achieve the following scenario:

  • user makes request xxxx-execute-api.eu-west-1.amazonaws.com/prod/api1/a/b/../n?param1=val1&parma2=val2...&paramn=valn request should go to api1.back.end/a/b/../n?param1=val1&parma2=val2...&paramn=valn

  • user makes request xxxx-execute-api.eu-west-1.amazonaws.com/prod/api2/a/b/../n?param1=val1&parma2=val2...&paramn=valn request should go to api2.back.end/a/b/../n?param1=val1&parma2=val2...&paramn=valn

  • user makes request xxxx-execute-api.eu-west-1.amazonaws.com/prod/*****/a/b/../n?param1=val1&parma2=val2...&paramn=valn request should go to api3.back.end/a/b/../n?param1=val1&parma2=val2...&paramn=valn

The routing should be done based on first path index after stage, and everything else after that should be passed to the http backend (like a transparent proxy).

In other words, if path index 1 is api1, forward request to api1.back.end with full URI after path index 1; if path index 1 is api2, forward request to api2.back.end with full URI after path index 1; if path index 1 is anything else than the explicit values api1 or api2, forward request to api3.back.end with full URI after path index 1;

How would I achieve this, without adding any extra layers (lambda, cloudfront, ec2, etc.) ?

Thank you!

1 Answer 1

3

API Gateway does not support this use case today; each method and path must be explicitly defined in your API definition.

Supporting such passthrough proxies is a request we have heard from other customers and we may consider supporting it in future updates to the service.

UPDATE 09/20/2016: I'm happy to announce that we've launched a set of features to allow for proxying of requests as described above. See our announcement for more details.

Sign up to request clarification or add additional context in comments.

3 Comments

While not ideal, you could perform this routing/redirection in Lambda, could you not? Either by returning a redirect or proxying a call to the target server, perhaps?
@ericpeters0n API Gateway would still need to support variable or "greedy" resource paths, which it does not. Currently you need to define every resource/method in your API Gateway definition and map this to an integration (e.g. Lambda).
Gist (for single-level path): create-resource --path-part '{proxy+}' --parent-id {ID of / root resource}; put-method --request-parameters method.request.path.proxy=true; put-integration --type HTTP_PROXY --uri 'http://downstream.domain/{basefile}' --request-parameters integration.request.path.basefile=method.request.path.proxy; create-deployment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.