Tuesday, August 23, 2022

List all GCP regions with Google (unofficial) API endpoint

I have several scenarios where I needed to list all GCP regions. (e.g. Cloud Billing API https://cloud.google.com/billing/docs/reference/rest).

I was surprised that there is no API for that. 

When you try to search "list of GCP regions" you will end with one of the top results to documentation e.g. https://cloud.google.com/compute/docs/regions-zones or https://cloud.google.com/about/locations. It is not suitable for programmatic access.

I have found recently an endpoint (not API!) with the list of IP ranges for each GCP regions


That was the last piece of the puzzle to create my desired function.

Here is a snippet for Google Apps Script:

Are you interested in this topic? Follow me on Twitter or subscribe RSS