Is it possible to connect a AWS API Gateway REST API to an external API? I guess the answer is yes since I was able to do this to a simple flask endpoint through an public IP on an EC2 instance. However, when I try to do this to an external public API endpoint I cannot figure out how to send the API Key for the remote API. The documentation really does not talk about this use case. Searching the web also did not provide any answers.
1 Answer
You will have to first configure your API Gateway API to have an HTTP integration. Add the URL of your external API in the integration config and then use Mapping Templates to add the API Key in the headers sent in the request to the external API.
If you are going to have a static value for the API key header, then it should be pretty straight forward following the above doc. If you plan to get it from the client, then you will have to map the incoming value to API Gateway API to the mapping template and then send it external API.