Discover External IP Range for Firebase Functions (Google Cloud Functions) by region?

123 Views Asked by At

I need to whitelist IP addresses for requests I am making from a Firebase Cloud Function to an external service. I don't want to stand up and run a VPC Connector and Cloud NAT Gateway for a full-time reserved outbound static IP because these requests are relatively infrequent and the external service can whitelist a range of IPs.

I thought I found the solution in this doc about Compute Engine ip ranges which points to this json resource that lists IP ranges by region.

BUT, when I tested this with the code below in two different Firebase projects, each in a different region, they both returned an outbound ip address that was not within the CIDR ranges specified in the json file (as far as I can tell).

So, my current best guess is that the published ranges in the json file are a subset of the potential external IPs that Google makes available to be assigned, but it is not a complete set of all possible external IPs you might see from a cloud function in that region. Or, it's possible that the list is for functions using the straight GCP product and doesn't cover Firebase Cloud Functions. Or something else?

I'm hoping I'm missing something and someone can help me understand this. Otherwise, Is there anyone out there who can point me to the actual complete ranges? I'm specifically interested in Firebase Cloud Functions running in us-west2.

Or another solution that doesn't require reserving a full-time static IP would also be great.

I ran the code below in us-west2 and us-central1. I tried over the course of many re-deploys, but got similar results each time.

The ip address I got for us-west2: 35.203.245.85 The ip address I got for us-central1: 107.178.200.230

As far as I can tell, these are Google-owned ip addresses, but they are not within the CIDR ranges for the current published list. I'm including the subset of the current list here for reference, since it may change.

Thank you!

exports.checkIP = functions
  .region("us-west2")
  .https.onCall(async (data, context) => {
    const response = await fetch("https://api.ipify.org?format=json");
    const jsonData = await response.json();
    logger.log("My outbound IP address is: ", jsonData.ip);
    return jsonData;
  });
{"ipv4Prefix": "34.20.128.0/17",
    "service": "Google Cloud",
    "scope": "us-west2"
  }, {
    "ipv4Prefix": "34.94.0.0/16",
    "service": "Google Cloud",
    "scope": "us-west2"
  }, {
    "ipv4Prefix": "34.102.0.0/17",
    "service": "Google Cloud",
    "scope": "us-west2"
  }, {
    "ipv4Prefix": "34.104.64.0/21",
    "service": "Google Cloud",
    "scope": "us-west2"
  }, {
    "ipv4Prefix": "34.108.0.0/16",
    "service": "Google Cloud",
    "scope": "us-west2"
  }, {
    "ipv4Prefix": "34.118.248.0/23",
    "service": "Google Cloud",
    "scope": "us-west2"
  }, {
    "ipv4Prefix": "34.124.0.0/21",
    "service": "Google Cloud",
    "scope": "us-west2"
  }, {
    "ipv4Prefix": "35.215.64.0/18",
    "service": "Google Cloud",
    "scope": "us-west2"
  }, {
    "ipv4Prefix": "35.220.47.0/24",
    "service": "Google Cloud",
    "scope": "us-west2"
  }, {
    "ipv4Prefix": "35.235.64.0/18",
    "service": "Google Cloud",
    "scope": "us-west2"
  }, {
    "ipv4Prefix": "35.236.0.0/17",
    "service": "Google Cloud",
    "scope": "us-west2"
  }, {
    "ipv4Prefix": "35.242.47.0/24",
    "service": "Google Cloud",
    "scope": "us-west2"
  }, {
    "ipv4Prefix": "35.243.0.0/21",
    "service": "Google Cloud",
    "scope": "us-west2"
  }, {
    "ipv6Prefix": "2600:1900:4120::/44",
    "service": "Google Cloud",
    "scope": "us-west2"
  }
...
{
    "ipv4Prefix": "8.34.210.0/24",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "8.34.212.0/22",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "8.34.216.0/22",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "8.35.192.0/21",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "23.236.48.0/20",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "23.251.144.0/20",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.0.225.0/24",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.16.0.0/17",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.27.0.0/16",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.28.0.0/14",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.33.0.0/16",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.41.0.0/16",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.42.0.0/16",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.44.0.0/15",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.46.0.0/16",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.66.0.0/15",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.68.0.0/14",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.72.0.0/16",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.118.200.0/21",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.121.0.0/16",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.122.0.0/15",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.128.32.0/22",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.132.0.0/14",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.136.0.0/16",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.157.84.0/23",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.157.96.0/20",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.157.212.0/23",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.157.224.0/20",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.170.0.0/15",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.172.0.0/15",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "34.177.52.0/22",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.184.0.0/16",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.188.0.0/17",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.188.128.0/18",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.188.192.0/19",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.192.0.0/15",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.194.0.0/18",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.202.0.0/16",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.206.64.0/18",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.208.0.0/15",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.220.64.0/19",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.222.0.0/15",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.224.0.0/15",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.226.0.0/16",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.232.0.0/16",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.238.0.0/15",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "35.242.96.0/19",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.154.16.0/20",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.154.32.0/19",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.154.64.0/19",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.154.96.0/20",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.154.113.0/24",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.154.114.0/23",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.154.116.0/22",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.154.120.0/23",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.154.128.0/17",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.155.128.0/18",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.197.0.0/16",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.198.16.0/20",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.198.32.0/19",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.198.64.0/20",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "104.198.128.0/17",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "107.178.208.0/20",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "108.59.80.0/21",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "130.211.112.0/20",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "130.211.128.0/18",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "130.211.192.0/19",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "130.211.224.0/20",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "146.148.32.0/19",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "146.148.64.0/19",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "146.148.96.0/20",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "162.222.176.0/21",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "173.255.112.0/21",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "199.192.115.0/24",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "199.223.232.0/22",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv4Prefix": "199.223.236.0/24",
    "service": "Google Cloud",
    "scope": "us-central1"
  }, {
    "ipv6Prefix": "2600:1900:4000::/44",
    "service": "Google Cloud",
    "scope": "us-central1"
  }

0

There are 0 best solutions below