Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS API Gateway with static IP

When you create an API using Gateway and map a custom domain, AWS API Gateway makes an entry in cloudfront distribution

source: http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html

For every API you create, API Gateway sets up an Amazon CloudFront distribution for the API. Requests with the default API URL are routed through the corresponding CloudFront distribution. Similarly, for every custom domain name, API Gateway sets up a CloudFront distribution. An API request with the custom domain name is routed through the custom domain name's CloudFront distribution.

However the cloudfront IPs can change when AWS updates the ip ranges.

As a user of the API, how do I bind a static IP to the custom domain mapped to Gateway so that I need not update firewall egress settings whenever AWS updates the IP ranges?

like image 715
suman j Avatar asked Sep 12 '17 18:09

suman j


People also ask

Does AWS API gateway have a static IP?

Public API Gateway can be invoked using a URL and does not reserve public static IP addresses.

Do API gateway IP addresses change?

IP Address ranges provided by AWS is provided as a JSON file here. These address ranges keep on changing.

Can Lambda have static IP?

By following the steps in this pattern, you can create a Lambda function and a virtual private cloud (VPC) that routes outbound traffic through an internet gateway with a static IP address. To use the static IP address, you attach the Lambda function to the VPC and its subnets.


2 Answers

It is not possible to attach a static IP to API Gateway. However, AWS Publishes the IP ranges used by CloudFront which can be used to whitelist the firewall egress settings.

Since these IP ranges also can change, it is recommended to automate the checking for changes using this URL and update the rules accordingly.

like image 178
Ashan Avatar answered Oct 13 '22 14:10

Ashan


Welcome to multi cloud ;-)

I was researching on this topic and found that there are solutions from other cloud providers.

  1. Google GCP : https://cloud.google.com/cdn/

    So google CDN do provide one anycast IP by default.

  2. Microsoft Azure API management https://azure.microsoft.com/en-us/services/api-management/ Do provide static IP.

In my opinion for AWS they solved the static IP problem with global accelerator or NLB but the problem is that both of these products are not layers 7 API management solutions.

So basically at this point , you can solve layer 4 but for layer 7 you need to use api gateway or cloud front and both don't have any direct integration with global accelerator or NLB.

In google solution atleast their CDN give only one anycast IP, which is not yet there in AWS cloudfront ( although matter of time )

I liked Microsoft API management for this particular case , where u get static ip + API management in one solution.

like image 29
user2117893 Avatar answered Oct 13 '22 14:10

user2117893