To be honest, I don’t see a direct way to do so. But there is a workaround to use static IP for API is to introduce a proxy between API Gateway and backend. In this approach you need to assign a static IP address to that proxy and whitelist it on the backend if it is required. This proxy could be an AWS Lambda function or an EC2 instance. Please note each proxy has its own advantages and limitations including scalability, accessibility, memory, timeouts, payload etc.
Here are the advantages and disadvantages of using either:
AWS Lambda
- You don’t need to manage servers
- More secured as proxy cannot be invoked externally bypassing API Gateway
- Exponential scalability
- AWS Lambda limitations such as memory, timeout, payload
EC2 instance
- More control on the server
- Can be used to overcome Lambda limitations of memory, timeout and payload sizes
- Can be accessed externally bypassing API Gateway
- Have to manually manage runtimes, apply security patches
No Comments