I'm looking after solution where AWS Api Gateway changes method endpoint Url dynamically. I am familiar with stage variables and in Integration request I can change endpoint per method like (https://${stageVariables.Url}/api/DoSomething). What I need is that information how parse endpoint is included in requests. https://${RequestData.Url}/api/DoSomething I have same Api in different locations and to implement centralized Api keys and logging services I try to forward all traffic through this one Api Gateway. After first request client gets its endpoint information, but I don't know how to solve that clients next requests to Gateway should forward to that endpoint which client get earlier.
2 Answers
I got an answer from AWS support. They told that I have to make a lambda function to process all requests or just use Stage variables.
2 Comments
Suresh
do you have any reference link or can you elaborate your answer?
JukkaT
I developed system where I have multiple stages with their own endpoint URL in stage variable. Client gets stage name as an first response and when following requests are made to that stage it will be forwarded to another backend. Another way around, clients have to be able to parse their requests to include stagename. ie. calls will be like api.testi.com/parsed_stagename/something/GET, This way I don't need lambda function in middle to processs and forward requests by header.
You can use a second API Gateway (Other API) that responde diferent for each ${RequestData.Url}.
This looks like:
- secondapigateway/bla001
- secondapigateway/bla002
- secondapigateway/bla003
Where bla001 ... are path parameters passed by first API Gateway.
For this, create an resource /{proxy+} for any http method. In Intregration Request put https://secondapigateway/{RequestData.Url}/{proxy}