Skip to content

_gcp

sc_crawler.vendors._gcp #

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 all available GCP disk storage options available in all zones.

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
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
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)
    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 all available GCP disk storage options available in all zones.

For more details on the disk types, check https://cloud.google.com/compute/docs/disks#disk-types.

Source code in sc_crawler/vendors/_gcp.py
def inventory_storages(vendor):
    """List all available GCP disk storage options available in all zones.

    For more details on the disk types, check <https://cloud.google.com/compute/docs/disks#disk-types>."""
    vendor.progress_tracker.start_task(
        name="Scanning zone(s) for storage(s)", total=len(vendor.zones)
    )

    def search_storages(zone: Zone, vendor: Vendor) -> List[dict]:
        zone_storages = []
        for storage in _storages(zone.name):
            valid_sizes = storage.valid_disk_size.replace("GB", "").split("-")
            zone_storages.append(
                {
                    "storage_id": str(storage.id),
                    "vendor_id": vendor.vendor_id,
                    "name": storage.name,
                    "description": storage.description,
                    "storage_type": (
                        StorageType.SSD
                        if storage.name != "pd-standard"
                        else StorageType.HDD
                    ),
                    "max_iops": None,
                    "max_throughput": None,
                    "min_size": int(valid_sizes[0]),
                    "max_size": int(valid_sizes[1]),
                }
            )
        vendor.log(f"{len(zone_storages)} storage(s) found in {zone.name}.")
        vendor.progress_tracker.advance_task()
        return zone_storages

    with ThreadPoolExecutor(max_workers=8) as executor:
        storages = executor.map(search_storages, vendor.zones, repeat(vendor))
    storages = list(chain.from_iterable(storages))

    vendor.log(f"{len(storages)} storage(s) found in {len(vendor.zones)} zones.")
    storages = list({p["name"]: p for p in storages}.values())
    vendor.log(f"{len(storages)} unique storage(s) found.")
    storages = [s for s in storages if s["name"] in STORAGE_ALLOWLIST]
    vendor.log(f"{len(storages)} storage(s) after dropping items with complex pricing.")
    vendor.progress_tracker.hide_task()
    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_regions = skus["storage"][storage.name].keys()
        for storage_region in storage_regions:
            # 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 = skus["storage"][storage.name][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)
        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
        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": 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,
            }
        )
        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