Search code examples
google-cloud-platformstatic-ip-addressgoogle-api-gateway

Static IP for GCP API Gateway


Is there a native option to setup a static IP address for a google cloud API Gateway? As far as I researched, looks like I have to setup a cloud load balancer in front of the API Gateway and then use the static IP of the load balancer. I am not sure how to do this. My goal is to only give access to my API gateway via IP address? I am looking for any documentation/articles on this regard. Thanks in advance.


Solution

  • I don't know and don't understand your requirement, but you can achieve this with a trick with HTTPS load balancer.

    • Create an external HTTPS load balancer. Use HTTP frontend (so not secure/encrypted) else you will have certificate's checks issues if you use HTTPS with a certificate and if you hit the IP.
    • Create an internet network endpoint group that points to your API Gateway URL
      • If it doesn't work, add a header in your backend service named host and with the API gateway base URL as value (without the https:// prefix)

    I don't like this design because you add a useless layer (and thus an additional (and useless) potential point of failure) and you will be charge for the load balancer (about $15 per month)