Skip to content

_gcp

sc_crawler.vendors._gcp #

Inventory of Google Cloud Platform via its APIs: servers, storages, traffic, IPv4 addresses and managed PostgreSQL (Cloud SQL), with their prices.

Functions:

Name Description
inventory_compliance_frameworks

Manual list of compliance frameworks known for GCP.

inventory_regions

List all available GCP regions via API calls.

inventory_zones

List all available GCP zones via API calls.

inventory_servers

List all available GCP servers available in all zones.

inventory_server_prices

List all available GCP server ondemand prices in all regions.

inventory_server_prices_spot

List all available GCP server spot prices in all regions.

inventory_storages

List GCP disk types for the storage catalog.

inventory_storage_prices

List all available GCP disk storage prices in all regions.

inventory_traffic_prices

List inbound and outbound network traffic prices in all GCP regions.

inventory_ipv4_prices

List the price of an attached IPv4 address in all GCP regions.

inventory_databases

List all available GCP Cloud SQL for PostgreSQL database types via API calls.

inventory_database_prices

List all available GCP Cloud SQL for PostgreSQL on-demand prices in all regions.

inventory_database_storages

List all available GCP Cloud SQL for PostgreSQL storage options.

inventory_database_storage_prices

List all available GCP Cloud SQL for PostgreSQL storage prices in all regions.

inventory_compliance_frameworks #

inventory_compliance_frameworks(vendor)

Manual list of compliance frameworks known for GCP.

Resources: https://cloud.google.com/compliance?hl=en

Source code in sc_crawler/vendors/_gcp.py
def inventory_compliance_frameworks(vendor):
    """Manual list of compliance frameworks known for GCP.

    Resources: <https://cloud.google.com/compliance?hl=en>"""
    return map_compliance_frameworks_to_vendor(
        vendor.vendor_id, ["hipaa", "soc2t2", "iso27001"]
    )

inventory_regions #

inventory_regions(vendor)

List all available GCP regions via API calls.

Some data sources are not available from APIs, and were collected manually:

Note that many GCP regions use more than 90% green energy, but the related flag in our database is set to False as not being 100%.

Source code in sc_crawler/vendors/_gcp.py
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
def inventory_regions(vendor):
    """List all available GCP regions via API calls.

    Some data sources are not available from APIs, and were collected manually:

    - location: <https://cloud.google.com/compute/docs/regions-zones#available> and <https://en.wikipedia.org/wiki/Google_data_centers>,
    - lon/lat coordinates: <https://en.wikipedia.org/wiki/Google_data_centers#Locations> and approximation based on the city when no more accurate data was available.
    - energy carbon data: <https://cloud.google.com/sustainability/region-carbon#data> and <https://github.com/GoogleCloudPlatform/region-carbon-info>,
    - launch dates were collected from [Wikipedia](https://en.wikipedia.org/wiki/Google_Cloud_Platform#Regions_and_zones) and GCP blog posts, such as <https://medium.com/@retomeier/an-annotated-history-of-googles-cloud-platform-90b90f948920> and <https://cloud.google.com/blog/products/infrastructure/introducing-new-google-cloud-regions>.

    Note that many GCP regions use more than 90% green energy,
    but the related flag in our database is set to `False` as not being 100%.
    """

    manual_data = {
        "africa-south1": {
            "country_id": "ZA",
            "city": "Johannesburg",
            # https://cloud.google.com/blog/products/infrastructure/heita-south-africa-new-cloud-region
            "founding_year": 2024,
            "green_energy": False,
            # approximation based on city
            "lat": -26.0420631,
            "lon": 28.0589808,
        },
        "asia-east1": {
            "country_id": "TW",
            "state": "Changhua County",
            "founding_year": 2013,
            "green_energy": False,
            "lat": 24.1385,
            "lon": 120.425722,
        },
        "asia-east2": {
            "country_id": "HK",
            # https://cloud.google.com/blog/products/gcp/gcps-region-in-hong-kong-is-now-open
            "founding_year": 2018,
            "green_energy": False,
            # approximation based on country
            "lat": 22.2772377,
            "lon": 114.1703066,
            "display_name": "Hong Kong",
        },
        "asia-northeast1": {
            "country_id": "JP",
            "city": "Tokyo",
            "state": "Japan",
            "founding_year": 2016,
            "green_energy": False,
            # approximation based on city
            "lat": 35.6433846,
            "lon": 139.7684933,
        },
        "asia-northeast2": {
            "country_id": "JP",
            "city": "Osaka",
            "founding_year": 2019,
            "green_energy": False,
            # approximation based on city
            "lat": 34.6696646,
            "lon": 135.4846612,
        },
        "asia-northeast3": {
            "country_id": "KR",
            "city": "Seoul",
            "founding_year": 2020,
            "green_energy": False,
            # approximation based on city
            "lat": 37.5514982,
            "lon": 126.97784,
        },
        "asia-south1": {
            "country_id": "IN",
            "city": "Mumbai",
            "founding_year": 2017,
            "green_energy": False,
            # approximation based on city
            "lat": 19.0709441,
            "lon": 72.8726468,
        },
        "asia-south2": {
            "country_id": "IN",
            "city": "Delhi",
            "founding_year": 2021,
            "green_energy": False,
            # approximation based on city
            "lat": 28.6439839,
            "lon": 76.9284239,
        },
        "asia-southeast1": {
            "country_id": "SG",
            "city": "Jurong West",
            "founding_year": 2017,
            "green_energy": False,
            "lat": 1.351333,
            "lon": 103.709778,
        },
        "asia-southeast2": {
            "country_id": "ID",
            "city": "Jakarta",
            "founding_year": 2020,
            "green_energy": False,
            # approximation based on city
            "lat": -6.2297401,
            "lon": 106.747117,
        },
        "asia-southeast3": {
            "country_id": "TH",
            "city": "Bangkok",
            "founding_year": 2025,
            "green_energy": False,
            # approximation based on city
            "lat": 15.870032,
            "lon": 100.992538,
        },
        "australia-southeast1": {
            "country_id": "AU",
            "city": "Sydney",
            "founding_year": 2017,
            "green_energy": False,
            # approximation based on city
            "lat": -33.8375583,
            "lon": 150.9488095,
        },
        "australia-southeast2": {
            "country_id": "AU",
            "city": "Melbourne",
            "founding_year": 2021,
            "green_energy": False,
            # approximation based on city
            "lat": -37.8038607,
            "lon": 144.7119569,
        },
        "europe-central2": {
            "country_id": "PL",
            "city": "Warsaw",
            "founding_year": 2021,
            "green_energy": False,
            # approximation based on city
            "lat": 52.2328871,
            "lon": 20.8966164,
        },
        "europe-north1": {
            "country_id": "FI",
            "city": "Hamina",
            "founding_year": 2018,
            "green_energy": False,
            "lat": 60.536578,
            "lon": 27.117003,
        },
        "europe-north2": {
            "country_id": "SE",
            "city": "Stockholm",
            "founding_year": 2025,
            "green_energy": False,
            # approximation based on city
            "lat": 59.334591,
            "lon": 18.06324,
        },
        "europe-southwest1": {
            "country_id": "ES",
            "city": "Madrid",
            "founding_year": 2022,
            "green_energy": False,
            "lat": 40.519533,
            "lon": -3.340937,
        },
        "europe-west1": {
            "country_id": "BE",
            "city": "St. Ghislain",
            # https://medium.com/@retomeier/an-annotated-history-of-googles-cloud-platform-90b90f948920
            "founding_year": 2015,
            "green_energy": False,
            "lat": 50.469333,
            "lon": 3.865472,
        },
        "europe-west10": {
            "country_id": "DE",
            "city": "Berlin",
            "founding_year": 2023,
            "green_energy": False,
            # approximation based on city
            "lat": 52.5105672,
            "lon": 13.3806972,
        },
        "europe-west12": {
            "country_id": "IT",
            "city": "Turin",
            "founding_year": 2023,
            "green_energy": False,
            "lat": 45.146729,
            "lon": 7.742147,
        },
        "europe-west2": {
            "country_id": "GB",
            "city": "London",
            "founding_year": 2017,
            "green_energy": False,
            # approximation based on city
            "lat": 51.5090133,
            "lon": -0.2118157,
        },
        "europe-west3": {
            "country_id": "DE",
            "city": "Frankfurt",
            "founding_year": 2017,
            "green_energy": False,
            "lat": 50.12263,
            "lon": 8.974168,
        },
        "europe-west4": {
            "country_id": "NL",
            "city": "Eemshaven",
            "founding_year": 2018,
            "green_energy": False,
            "lat": 52.790105,
            "lon": 5.029219,
        },
        "europe-west6": {
            "country_id": "CH",
            "city": "Zurich",
            "founding_year": 2019,
            "green_energy": False,
            "lat": 47.445926,
            "lon": 8.210909,
        },
        "europe-west8": {
            "country_id": "IT",
            "city": "Milan",
            "founding_year": 2022,
            "green_energy": False,
            # approximation based on city
            "lat": 45.4615551,
            "lon": 9.1389572,
        },
        "europe-west9": {
            "country_id": "FR",
            "city": "Paris",
            "founding_year": 2022,
            "green_energy": False,
            # approximation based on city
            "lat": 48.8641797,
            "lon": 2.3109137,
        },
        "me-central1": {
            "country_id": "QA",
            "city": "Doha",
            "founding_year": 2023,
            "green_energy": False,
            # approximation based on city
            "lat": 25.272868,
            "lon": 51.4717522,
        },
        "me-central2": {
            "country_id": "SA",
            "city": "Dammam",
            "founding_year": 2023,
            "green_energy": False,
            # approximation based on city
            "lat": 26.3826288,
            "lon": 49.9675732,
        },
        "me-west1": {
            "country_id": "IL",
            "city": "Tel Aviv",
            "founding_year": 2022,
            "green_energy": False,
            # approximation based on city
            "lat": 32.0491183,
            "lon": 34.7891105,
        },
        "northamerica-northeast1": {
            "country_id": "CA",
            "city": "Montréal",
            "founding_year": 2018,
            "green_energy": True,
            # approximation based on city
            "lat": 45.4933996,
            "lon": -73.728239,
        },
        "northamerica-northeast2": {
            "country_id": "CA",
            "city": "Toronto",
            "founding_year": 2021,
            "green_energy": False,
            # approximation based on city
            "lat": 43.72666,
            "lon": -79.5355309,
        },
        "southamerica-east1": {
            "country_id": "BR",
            "city": "Osasco",
            "state": "São Paulo",
            "founding_year": 2017,
            "green_energy": False,
            # approximation based on city
            "lat": -23.5267431,
            "lon": -46.8096539,
        },
        "southamerica-west1": {
            "country_id": "CL",
            "city": "Santiago",
            "founding_year": 2021,
            "green_energy": False,
            "lat": -33.520515,
            "lon": -70.721695,
        },
        # NOTE this is not announced yet, but showing up in API from time to time
        "northamerica-south1": {
            # https://mexicobusiness.news/cloudanddata/news/google-cloud-announces-first-mexican-data-region-queretaro
            "country_id": "MX",
            "city": "Queretaro",
            "founding_year": 2025,
            "green_energy": False,
            # approximation based on city
            "lat": 20.5896,
            "lon": -100.3897,
        },
        "us-central1": {
            "country_id": "US",
            "city": "Council Bluffs",
            "state": "Iowa",
            "founding_year": 2009,
            "green_energy": False,
            "lat": 41.168253,
            "lon": -95.796125,
        },
        "us-east1": {
            "country_id": "US",
            "city": "Moncks Corner",
            "state": "South Carolina",
            "founding_year": 2015,
            "green_energy": False,
            "lat": 33.064111,
            "lon": -80.043361,
        },
        "us-east4": {
            "country_id": "US",
            "city": "Ashburn",
            "state": "Virginia",
            "founding_year": 2017,
            "green_energy": False,
            "lat": 38.943331,
            "lon": -77.524336,
        },
        "us-east5": {
            "country_id": "US",
            "city": "Columbus",
            "state": "Ohio",
            "founding_year": 2022,
            "green_energy": False,
            # approximation based on city
            "lat": 39.9773124,
            "lon": -83.0423282,
        },
        "us-south1": {
            "country_id": "US",
            "city": "Dallas",
            "state": "Texas",
            "founding_year": 2022,
            "green_energy": False,
            "lat": 32.44317,
            "lon": -97.062324,
        },
        "us-west1": {
            "country_id": "US",
            "city": "The Dalles",
            "state": "Oregon",
            "founding_year": 2016,
            "green_energy": False,
            "lat": 45.632511,
            "lon": -121.202267,
        },
        "us-west2": {
            "country_id": "US",
            "city": "Los Angeles",
            "state": "California",
            "founding_year": 2018,
            "green_energy": False,
            # approximation based on city
            "lat": 34.0549694,
            "lon": -118.3753618,
        },
        "us-west3": {
            "country_id": "US",
            "city": "Salt Lake City",
            "state": "Utah",
            "founding_year": 2020,
            "green_energy": False,
            # approximation based on city
            "lat": 40.7386099,
            "lon": -111.9609998,
        },
        "us-west4": {
            "country_id": "US",
            "city": "Las Vegas",
            "state": "Nevada",
            "founding_year": 2020,
            "green_energy": False,
            "lat": 36.055625,
            "lon": -115.010226,
        },
    }

    # add API reference and display names
    for k, v in manual_data.items():
        v["api_reference"] = k
        if v.get("display_name") is None:
            v["display_name"] = v.get("city", v.get("state", ""))
            if v.get("display_name"):
                v["display_name"] = v["display_name"] + " (" + v["country_id"] + ")"
            else:
                v["display_name"] = v["country_id"]

    regions = _regions()
    items = []
    for region in regions:
        with sentry_capture_or_raise(vendor=vendor):
            if region.name not in manual_data:
                raise KeyError(f"Unknown region metadata for {region.name}")
            item = {
                "vendor_id": vendor.vendor_id,
                "region_id": str(region.id),
                "name": region.name,
            }
            for k, v in manual_data[region.name].items():
                item[k] = v
            items.append(item)
    return items

inventory_zones #

inventory_zones(vendor)

List all available GCP zones via API calls.

Source code in sc_crawler/vendors/_gcp.py
def inventory_zones(vendor):
    """List all available GCP zones via API calls."""
    items = []
    regions = scmodels_to_dict(vendor.regions, keys=["name"])
    for zone in _zones():
        items.append(
            {
                "vendor_id": vendor.vendor_id,
                # example `zone.region`:
                # https://www.googleapis.com/compute/v1/projects/algebraic-pier-412621/regions/us-east4
                "region_id": regions[zone.region.split("/")[-1]].region_id,
                "zone_id": str(zone.id),
                "name": zone.name,
                "api_reference": zone.name,
                "display_name": zone.name,
            }
        )
    return items

inventory_servers #

inventory_servers(vendor)

List all available GCP servers available in all zones.

Lifecycle (machineTypes.deprecated.state): DEPRECATED -> PLANNED_FOR_RETIREMENT, OBSOLETE / DELETED -> RETIRED, empty / ACTIVE -> ACTIVE. See _gcp_machine_type_status.

Source code in sc_crawler/vendors/_gcp.py
def inventory_servers(vendor):
    """List all available GCP servers available in all zones.

    Lifecycle (`machineTypes.deprecated.state`): DEPRECATED -> PLANNED_FOR_RETIREMENT,
    OBSOLETE / DELETED -> RETIRED, empty / ACTIVE -> ACTIVE.
    See `_gcp_machine_type_status`.
    """
    servers = parallel_fetch_servers(vendor, _search_servers, "name", "zones")
    servers = preprocess_servers(servers, vendor, add_vendor_id)

    # storage name -> storage ID, taken from the current storage inventory
    # (not from the database, which can be missing or stale in a servers-only pull)
    storages = {s["name"]: s["storage_id"] for s in inventory_storages(vendor)}
    for server in servers:
        names = _compatible_storage_names(server)
        if names is None:
            # series missing from the support tables: unknown, not "no storage"
            server["compatible_storage_ids"] = None
            continue
        ids = []
        for name in names:
            if name in storages:
                ids.append(storages[name])
            else:
                vendor.log(f"Storage '{name}' not found for {server['name']}", WARNING)
        server["compatible_storage_ids"] = ids
    return servers

inventory_server_prices #

inventory_server_prices(vendor)

List all available GCP server ondemand prices in all regions.

Prices cover the predefined vCPU, memory, attached GPUs, and bundled Local SSD (from machineTypes.bundledLocalSsds).

Source code in sc_crawler/vendors/_gcp.py
def inventory_server_prices(vendor):
    """List all available GCP server ondemand prices in all regions.

    Prices cover the predefined vCPU, memory, attached GPUs, and bundled Local
    SSD (from `machineTypes.bundledLocalSsds`).
    """
    return _inventory_server_prices(vendor, Allocation.ONDEMAND)

inventory_server_prices_spot #

inventory_server_prices_spot(vendor)

List all available GCP server spot prices in all regions.

Same components as inventory_server_prices (including bundled Local SSD).

Source code in sc_crawler/vendors/_gcp.py
def inventory_server_prices_spot(vendor):
    """List all available GCP server spot prices in all regions.

    Same components as `inventory_server_prices` (including bundled Local SSD).
    """
    return _inventory_server_prices(vendor, Allocation.SPOT)

inventory_storages #

inventory_storages(vendor)

List GCP disk types for the storage catalog.

Allowlisted zonal types (PD + Hyperdisk) share the same name/specs in every zone, so one zone is enough. Hyperdisk Balanced HA is regional-only (regionDiskTypes) and is not a zonal type. See https://cloud.google.com/compute/docs/disks#disk-types and https://cloud.google.com/compute/docs/disks/hyperdisks.

Source code in sc_crawler/vendors/_gcp.py
def inventory_storages(vendor):
    """List GCP disk types for the storage catalog.

    Allowlisted zonal types (PD + Hyperdisk) share the same name/specs in every
    zone, so one zone is enough. Hyperdisk Balanced HA is regional-only
    (`regionDiskTypes`) and is not a zonal type.
    See <https://cloud.google.com/compute/docs/disks#disk-types>
    and <https://cloud.google.com/compute/docs/disks/hyperdisks>.
    """

    def _record(storage) -> dict:
        valid_sizes = storage.valid_disk_size.replace("GB", "").split("-")
        perf = STORAGE_PERFORMANCE[storage.name]
        return {
            "storage_id": str(storage.id),
            "vendor_id": vendor.vendor_id,
            "name": storage.name,
            "description": storage.description,
            "storage_type": (
                StorageType.HDD if storage.name == "pd-standard" else StorageType.SSD
            ),
            "max_iops": perf["max_iops"],
            "max_throughput": perf["max_throughput"],
            "min_size": int(valid_sizes[0]),
            "max_size": int(valid_sizes[1]),
        }

    ha_name = "hyperdisk-balanced-high-availability"
    by_name: dict[str, dict] = {}
    for zone in vendor.zones:
        for storage in _storages(zone.name):
            if storage.name not in STORAGE_ALLOWLIST or storage.name == ha_name:
                continue
            by_name[storage.name] = _record(storage)
        if by_name:
            vendor.log(f"{len(by_name)} storage(s) found in {zone.name}.")
            break

    # Hyperdisk Balanced HA is regional-only (regionDiskTypes).
    for region in vendor.regions:
        for storage in _region_storages(region.name):
            if storage.name != ha_name:
                continue
            by_name[ha_name] = _record(storage)
            vendor.log(f"1 regional storage(s) found in {region.name}.")
            break
        if ha_name in by_name:
            break

    storages = list(by_name.values())
    vendor.log(f"{len(storages)} unique storage(s) found.")
    return storages

inventory_storage_prices #

inventory_storage_prices(vendor)

List all available GCP disk storage prices in all regions.

Source code in sc_crawler/vendors/_gcp.py
def inventory_storage_prices(vendor):
    """List all available GCP disk storage prices in all regions."""
    regions = scmodels_to_dict(vendor.regions, keys=["name"])
    skus = _skus_dict()
    items = []
    for storage in vendor.storages:
        storage_skus = skus["storage"].get(storage.name)
        if not storage_skus:
            vendor.log(
                f"Skip '{storage.name}': no capacity SKU in billing catalog",
                DEBUG,
            )
            continue
        for storage_region in storage_skus.keys():
            # skip edge regions
            region = regions.get(storage_region)
            if region is None:
                vendor.log(
                    f"Skip unknown '{storage_region}' region for {storage.name}",
                    DEBUG,
                )
                continue

            price, currency = storage_skus[storage_region]["ondemand"]
            for zone in region.zones:
                items.append(
                    {
                        "vendor_id": vendor.vendor_id,
                        "region_id": region.region_id,
                        "storage_id": storage.storage_id,
                        "unit": PriceUnit.GB_MONTH,
                        "price": float(price),
                        "currency": currency,
                    }
                )
    return items

inventory_traffic_prices #

inventory_traffic_prices(vendor)

List inbound and outbound network traffic prices in all GCP regions.

Source code in sc_crawler/vendors/_gcp.py
def inventory_traffic_prices(vendor):
    """List inbound and outbound network traffic prices in all GCP regions."""
    regions = scmodels_to_dict(vendor.regions, keys=["name"])
    skus = _skus("Compute Engine")
    items = []
    for sku in skus:
        # skip not processed items early
        if sku.category.resource_family != "Network":
            continue
        if sku.category.resource_group not in [
            "StandardInternetEgress",
            "StandardInternetIngress",
        ]:
            continue

        # helper variables
        traffic_regions = sku.service_regions
        tiered_rates = sku.pricing_info[0].pricing_expression.tiered_rates
        price_tiers = []
        for i in range(len(tiered_rates)):
            price_tiers.append(
                {
                    "lower": tiered_rates[i].start_usage_amount,
                    "upper": "Infinity"
                    if i == len(tiered_rates) - 1
                    else tiered_rates[i + 1].start_usage_amount,
                    "price": tiered_rates[i].unit_price.nanos / 1e9,
                }
            )

        for traffic_region in traffic_regions:
            region = regions.get(traffic_region)
            if region is None:
                vendor.log(
                    f"Skip unknown '{traffic_region}' region for {sku.description}",
                    DEBUG,
                )
                continue
            items.append(
                {
                    "vendor_id": vendor.vendor_id,
                    "region_id": region.region_id,
                    "price": max([float(t["price"]) for t in price_tiers]),
                    "price_tiered": price_tiers,
                    "currency": tiered_rates[0].unit_price.currency_code,
                    "unit": PriceUnit.GB_MONTH,
                    "direction": (
                        TrafficDirection.OUT
                        if sku.category.resource_group == "StandardInternetEgress"
                        else TrafficDirection.IN
                    ),
                }
            )

    return items

inventory_ipv4_prices #

inventory_ipv4_prices(vendor)

List the price of an attached IPv4 address in all GCP regions.

Note that this data was not found using the APIs (only unattached static IPs), so the values are recorded manually from https://cloud.google.com/vpc/network-pricing#ipaddress.

Source code in sc_crawler/vendors/_gcp.py
def inventory_ipv4_prices(vendor):
    """List the price of an attached IPv4 address in all GCP regions.

    Note that this data was not found using the APIs (only unattached static IPs),
    so the values are recorded manually from <https://cloud.google.com/vpc/network-pricing#ipaddress>.
    """
    # skus = _skus("Compute Engine")
    # for sku in skus:
    #     if sku.category.resource_family != "Network":
    #         continue
    #     if sku.description == "Static Ip Charge":
    #         pass
    items = []
    for region in vendor.regions:
        items.append(
            {
                "vendor_id": vendor.vendor_id,
                "region_id": region.region_id,
                "price": 0.005,
                "currency": "USD",
                "unit": PriceUnit.HOUR,
            }
        )
    return items

inventory_databases #

inventory_databases(vendor)

List all available GCP Cloud SQL for PostgreSQL database types via API calls.

Source code in sc_crawler/vendors/_gcp.py
def inventory_databases(vendor):
    """List all available GCP Cloud SQL for PostgreSQL database types via API calls."""
    vendor.progress_tracker.start_task(name="Fetching PostgreSQL tier(s)", total=None)
    meta = _pg_sqladmin_metadata()
    _, ha_families = _pg_billing_catalog()
    vendor.progress_tracker.hide_task()

    rows = []
    tiers = meta["tiers"]
    vendor.progress_tracker.start_task(name="Processing database(s)", total=len(tiers))
    for tier in tiers:
        tier_name = tier.get("tier")
        if not tier_name:
            vendor.progress_tracker.advance_task()
            continue
        # Skip custom shapes (db-custom-*), catalog predefined tiers only.
        # https://cloud.google.com/sql/docs/postgres/machine-series-overview
        if tier_name.startswith("db-custom-"):
            vendor.progress_tracker.advance_task()
            continue

        if match := _PG_NAMED_TIER_CPU_RE.search(tier_name):
            cpu_count = int(match.group(1))
        else:
            cpu_count = None

        ram_bytes = int(tier.get("RAM") or 0)
        memory_amount = int(ram_bytes / 1_048_576) if ram_bytes else None

        stripped = tier_name.removeprefix("db-")
        parts = stripped.split("-")
        family_slug = (
            "-".join(parts[:-1]) if parts and parts[-1].isdigit() else stripped
        )

        spec_parts: list[str] = []
        if cpu_count is not None:
            spec_parts.append(f"{cpu_count} vCPU{'s' if cpu_count != 1 else ''}")
        if memory_amount is not None:
            memory_gib = round(memory_amount / 1024, 1)
            gib_label = (
                f"{int(memory_gib)} GB RAM"
                if memory_gib == int(memory_gib)
                else f"{memory_gib:g} GB RAM"
            )
            spec_parts.append(gib_label)
        tier_family, tier_series = _pg_tier_family_series(family_slug)
        family_label = _PG_TIER_FAMILY_LABELS.get(
            family_slug, family_slug.replace("-", " ").title()
        )
        description = f"PostgreSQL Cloud SQL {family_label}"
        if spec_parts:
            description = f"{description} ({', '.join(spec_parts)})"
        server = next(
            (
                item
                for item in vendor.servers
                if item.api_reference == tier_name.removeprefix("db-")
            ),
            None,
        )
        server_id = server.server_id if server is not None else None
        status = server.status if server is not None else Status.ACTIVE
        retirement_date = server.retirement_date if server is not None else None
        raw_regions = tier.get("region")
        if isinstance(raw_regions, str):
            tier_regions = [raw_regions]
        elif isinstance(raw_regions, list):
            tier_regions = [region for region in raw_regions if isinstance(region, str)]
        else:
            tier_regions = []

        sku_family = _pg_sku_family(tier_name)
        is_enterprise_plus = sku_family.startswith("enterprise_plus")
        engine_versions = [
            version
            for version in meta["engine_versions"]
            if version in _PG_SUPPORTED_MAJOR_VERSIONS
        ]
        if is_enterprise_plus:
            plus_versions = _PG_ENTERPRISE_PLUS_MAJOR_VERSIONS
            if sku_family == "enterprise_plus_c4a":
                # PostgreSQL 12 is unsupported on C4A only, not on N2 / C4.
                # https://cloud.google.com/sql/docs/postgres/machine-series-overview
                plus_versions = plus_versions - {"12"}
            engine_versions = [
                version for version in engine_versions if version in plus_versions
            ]

        ha: list[DatabaseHaLevel] = []
        ha_strategy: list[DatabaseHaStrategy] = []
        has_regional_ha = False
        if tier_regions:
            # https://cloud.google.com/sql/docs/postgres/high-availability
            # Regional billing meters -> same-region multi-zone HA (standby).
            # Zonal billing meters -> non-HA.
            # Enterprise Plus Advanced DR -> cross-region replica promotion (not multi-region HA).
            has_regional_ha = any(
                (region, sku_family) in ha_families for region in tier_regions
            )
            if has_regional_ha:
                ha.append(DatabaseHaLevel.MULTI_ZONE)
                ha_strategy.append(DatabaseHaStrategy.PASSIVE_STANDBY)
        ha.append(DatabaseHaLevel.NONE)
        ha_strategy.append(DatabaseHaStrategy.NONE)

        disk_quota_bytes = int(tier.get("DiskQuota") or 0)
        storage_extra_max = (
            disk_quota_bytes // 1_000_000_000 if disk_quota_bytes else None
        )

        rows.append(
            {
                "vendor_id": vendor.vendor_id,
                "database_id": tier_name,
                "name": tier_name,
                "api_reference": tier_name,
                # https://www.pulumi.com/registry/packages/gcp/api-docs/sql/databaseinstance/
                # Machine size lives under settings (Pulumi DatabaseInstance.settings.tier).
                "api_reference_object": {"settings": {"tier": tier_name}},
                "display_name": tier_name,
                "description": description,
                # TODO: not clear which are the server instances for for perf-optimized and memory-optimized
                # db instances (like db-perf-optimized-N-2, db-memory-optimized-N-4, etc.)
                "server_id": server_id,
                "engine": DatabaseEngine.POSTGRESQL,
                "wire_protocol": DatabaseWireProtocol.POSTGRESQL,
                "engine_versions": engine_versions,
                "family": tier_family,
                "series": tier_series,
                "compatible_storage_ids": _pg_tier_storage_ids(family_slug),
                "vcpus": cpu_count,
                "memory_amount": memory_amount,
                "storage_size": None,
                "ha": DatabaseHaLevel.ordered(ha),
                "ha_strategy": DatabaseHaStrategy.ordered(ha_strategy),
                # https://cloud.google.com/sql/docs/postgres/configure-ip
                # https://cloud.google.com/sql/docs/postgres/private-ip
                # https://cloud.google.com/sql/docs/postgres/configure-private-service-connect
                # https://cloud.google.com/sql/docs/postgres/iam-authentication
                # https://cloud.google.com/sql/docs/postgres/configure-ssl-instance
                # https://cloud.google.com/sql/docs/postgres/cmek
                # https://cloud.google.com/sql/docs/postgres/pg-audit
                # Authorized networks, private IP (PSA tenant VPC), PSC, IAM DB auth,
                # sslMode (ENCRYPTED_ONLY / client certs), CMEK, pgaudit.
                "security_features": [
                    DatabaseSecurityFeature.IP_FILTERING,
                    DatabaseSecurityFeature.PRIVATE_NETWORK,
                    DatabaseSecurityFeature.NETWORK_PEERING,
                    DatabaseSecurityFeature.IDENTITY_BASED_AUTH,
                    DatabaseSecurityFeature.CLIENT_CERT_AUTH,
                    DatabaseSecurityFeature.ENFORCED_TLS,
                    DatabaseSecurityFeature.CUSTOMER_MANAGED_KEYS,
                    DatabaseSecurityFeature.AUDIT_LOGGING,
                ],
                # https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/instances
                # Minimum data disk size is 10 GB.
                "storage_extra_min": 10,
                "storage_extra_max": storage_extra_max,
                # https://cloud.google.com/sql/docs/postgres/instance-settings
                "storage_extra_autosize": True,
                # https://cloud.google.com/sql/docs/postgres/cmek
                "disk_encryption": True,
                # https://cloud.google.com/sql/docs/postgres/maintenance
                # Minor versions are applied via Cloud SQL maintenance updates.
                "auto_upgrade_versions": True,
                # https://cloud.google.com/sql/docs/postgres/backup-recovery/backups
                "scheduled_backups": True,
                # https://cloud.google.com/sql/docs/postgres/backup-recovery/configure-pitr
                # Max transactionLogRetentionDays for PITR by edition; not in tiers API.
                # Enterprise: 1-7 days; Enterprise Plus: 1-35 days.
                "continuous_backups": (35 if is_enterprise_plus else 7),
                "custom_config": meta["custom_config"],
                "custom_extensions": meta["custom_extensions"],
                # https://cloud.google.com/sql/docs/postgres/replication
                # Shared-core tiers do not support read replicas.
                # Up to 10 replicas per primary (cascading also allowed).
                "max_read_replicas": (0 if tier_name in _PG_SHARED_TIERS else 10),
                # https://cloud.google.com/sql/docs/postgres/managed-connection-pooling
                "connection_pool": True,
                # https://cloud.google.com/sql/docs/postgres/monitor-instance
                "system_monitoring": True,
                # https://cloud.google.com/sql/docs/postgres/using-query-insights
                "database_monitoring": True,
                # https://cloud.google.com/sql/docs/postgres/use-index-advisor
                # Index advisor recommends CREATE INDEX (Enterprise Plus only); operator applies.
                "autotuning_advice": is_enterprise_plus,
                "autotuning_apply": False,
                # https://cloud.google.com/sql/sla
                # Enterprise Plus + HA: 99.99%; Enterprise + HA: 99.95%.
                # Shared-core and zonal (non-HA) instances are excluded from the SLA.
                "sla": (
                    99.99
                    if is_enterprise_plus and has_regional_ha
                    else (
                        99.95
                        if DatabaseHaLevel.MULTI_ZONE in ha
                        and tier_name not in _PG_SHARED_TIERS
                        else None
                    )
                ),
                "status": status,
                "retirement_date": retirement_date,
            }
        )
        vendor.progress_tracker.advance_task()
    vendor.progress_tracker.hide_task()
    return rows

inventory_database_prices #

inventory_database_prices(vendor)

List all available GCP Cloud SQL for PostgreSQL on-demand prices in all regions.

Source code in sc_crawler/vendors/_gcp.py
def inventory_database_prices(vendor):
    """List all available GCP Cloud SQL for PostgreSQL on-demand prices in all regions."""
    vendor.progress_tracker.start_task(name="Fetching Cloud SQL SKU(s)", total=None)
    compute_index, _ = _pg_billing_catalog()
    tiers = _pg_sqladmin_metadata()["tiers"]
    vendor.progress_tracker.hide_task()

    items = []
    vendor.progress_tracker.start_task(
        name="Processing database_price(s)", total=len(tiers)
    )
    for tier in tiers:
        tier_name = tier.get("tier")
        if not tier_name:
            vendor.progress_tracker.advance_task()
            continue
        if tier_name.startswith("db-custom-"):
            vendor.progress_tracker.advance_task()
            continue

        if match := _PG_NAMED_TIER_CPU_RE.search(tier_name):
            cpu_count = int(match.group(1))
        else:
            cpu_count = None

        ram_bytes = int(tier.get("RAM") or 0)
        memory_gib = ram_bytes / (1024**3) if ram_bytes else None

        raw_regions = tier.get("region")
        if isinstance(raw_regions, str):
            tier_regions = {raw_regions}
        elif isinstance(raw_regions, list):
            tier_regions = {region for region in raw_regions if isinstance(region, str)}
        else:
            tier_regions = set()

        sku_family = _pg_sku_family(tier_name)
        availabilities = ("zonal", "regional")

        for region in vendor.regions:
            if tier_regions and region.api_reference not in tier_regions:
                continue

            for availability in availabilities:
                hourly = currency = None
                if sku_family == "shared":
                    component = _PG_SHARED_TIERS[tier_name]
                    instance_sku = compute_index.get(
                        (region.api_reference, "shared", component, availability)
                    )
                    if instance_sku is not None:
                        hourly = _sku_unit_price(instance_sku)
                        if hourly is not None:
                            tiered = instance_sku.pricing_info[
                                0
                            ].pricing_expression.tiered_rates
                            currency = tiered[0].unit_price.currency_code or "USD"
                elif cpu_count is not None and memory_gib is not None:
                    vcpu_sku = compute_index.get(
                        (region.api_reference, sku_family, "vcpu", availability)
                    )
                    ram_sku = compute_index.get(
                        (region.api_reference, sku_family, "ram", availability)
                    )
                    if vcpu_sku is not None and ram_sku is not None:
                        vcpu_hourly = _sku_unit_price(vcpu_sku)
                        ram_hourly = _sku_unit_price(ram_sku)
                        if vcpu_hourly is not None and ram_hourly is not None:
                            hourly = vcpu_hourly * cpu_count + ram_hourly * memory_gib
                            vcpu_tiered = vcpu_sku.pricing_info[
                                0
                            ].pricing_expression.tiered_rates
                            currency = vcpu_tiered[0].unit_price.currency_code or "USD"

                if hourly is None:
                    continue
                # https://cloud.google.com/sql/docs/postgres/high-availability
                # Zonal = standalone; Regional HA = multi-zone standby (exactly 2x on
                # the pricing page; we use Regional billing SKUs, not a multiplier).
                if availability == "regional":
                    ha = DatabaseHaLevel.MULTI_ZONE
                    ha_strategy = DatabaseHaStrategy.PASSIVE_STANDBY
                else:
                    ha = DatabaseHaLevel.NONE
                    ha_strategy = DatabaseHaStrategy.NONE
                items.append(
                    {
                        "vendor_id": vendor.vendor_id,
                        "region_id": region.region_id,
                        "database_id": tier_name,
                        "allocation": Allocation.ONDEMAND,
                        "ha": ha,
                        "ha_strategy": ha_strategy,
                        "unit": PriceUnit.HOUR,
                        "price": hourly,
                        "price_upfront": 0,
                        "price_tiered": [],
                        "currency": currency or "USD",
                    }
                )
        vendor.progress_tracker.advance_task()
    vendor.progress_tracker.hide_task()
    return items

inventory_database_storages #

inventory_database_storages(vendor)

List all available GCP Cloud SQL for PostgreSQL storage options.

Source code in sc_crawler/vendors/_gcp.py
def inventory_database_storages(vendor):
    """List all available GCP Cloud SQL for PostgreSQL storage options."""
    vendor.progress_tracker.start_task(name="Fetching Cloud SQL SKU(s)", total=None)
    found = {
        storage_id
        for sku in _cloud_sql_skus()
        if (storage_id := _pg_storage_id(sku.description or ""))
    }
    vendor.progress_tracker.hide_task()

    items = []
    vendor.progress_tracker.start_task(
        name="Processing database_storage(s)", total=len(found)
    )
    for storage_id in sorted(found):
        spec = _PG_STORAGE_SPECS[storage_id]
        items.append(
            {
                "vendor_id": vendor.vendor_id,
                "database_storage_id": storage_id,
                "name": spec["name"],
                "description": spec["description"],
                "scope": DatabaseStorageScope.DATA,
                "min_size": spec["min_size"],
                "max_size": spec["max_size"],
                "max_iops": spec["max_iops"],
                "max_throughput": spec["max_throughput"],
            }
        )
        vendor.progress_tracker.advance_task()
    vendor.progress_tracker.hide_task()
    return items

inventory_database_storage_prices #

inventory_database_storage_prices(vendor)

List all available GCP Cloud SQL for PostgreSQL storage prices in all regions.

Source code in sc_crawler/vendors/_gcp.py
def inventory_database_storage_prices(vendor):
    """List all available GCP Cloud SQL for PostgreSQL storage prices in all regions."""
    vendor.progress_tracker.start_task(name="Fetching Cloud SQL SKU(s)", total=None)
    skus = _cloud_sql_skus()
    vendor.progress_tracker.hide_task()

    items = []
    seen: set[tuple[str, str]] = set()
    vendor.progress_tracker.start_task(
        name="Processing database_storage_price(s)", total=len(skus)
    )
    for sku in skus:
        storage_id = _pg_storage_id(sku.description or "")
        if not storage_id:
            vendor.progress_tracker.advance_task()
            continue

        unit_price = _sku_unit_price(sku)
        if unit_price is None:
            vendor.progress_tracker.advance_task()
            continue
        usage_unit = (
            sku.pricing_info[0].pricing_expression.usage_unit
            if sku.pricing_info
            else ""
        )
        if usage_unit == "GiBy.mo":
            monthly = unit_price
        elif usage_unit == "GiBy.h":
            monthly = unit_price * 730
        else:
            vendor.progress_tracker.advance_task()
            continue

        tiered = sku.pricing_info[0].pricing_expression.tiered_rates
        currency = tiered[0].unit_price.currency_code or "USD"
        for region in vendor.regions:
            if region.api_reference not in sku.service_regions:
                continue
            key = (region.region_id, storage_id)
            if key in seen:
                continue
            seen.add(key)
            items.append(
                {
                    "vendor_id": vendor.vendor_id,
                    "region_id": region.region_id,
                    "database_storage_id": storage_id,
                    "unit": PriceUnit.GB_MONTH,
                    "price": monthly,
                    "price_upfront": 0,
                    "price_tiered": [],
                    "currency": currency,
                }
            )
        vendor.progress_tracker.advance_task()
    vendor.progress_tracker.hide_task()
    return items