Part 2: Services & APIs: Building a Reliable Inventory Baseline

AuthorEmmanuel Secretaria

Published Aug 9, 2025

Learn how to enumerate enabled APIs and interpret the service footprint that powers each GCP environment.

Share

Scope inspiration:** gcp_info.sh, gcp_info_services.sh, gcp_service_apis.sh.

This series follows the repo’s GCP inventory flow so every step builds a repeatable, audit-friendly picture of your environment. Part 2 locks down the Services & APIs layer so you only query what’s actually enabled.


What this script does (walkthrough)

The services inventory is the gating step for the rest of the discovery flow. The scripts deliberately build a list of enabled APIs first and then use that list to avoid noisy failures later.

  1. Generate a service catalog via
    gcp_service_apis.sh
    (if not already loaded).
  2. List enabled services with
    gcloud services list --enabled
    so the report reflects actual API usage.
  3. Feed the enabled list to downstream sections, letting
    is_service_enabled
    guard feature-specific calls.

Operational caveats and gotchas

  • The script explicitly hydrates the service list only once. If you toggle APIs mid-session, you should re-run the script to refresh the baseline.
  • gcp_info_services.sh
    assumes your project is already set (Part 1), because it uses the current project to determine which APIs are enabled.
  • Output is intentionally lean: the goal is a baseline inventory, not a full per-service deep dive.

Example command usage

# Enumerate enabled APIs for the active project
gcp/gcp_info_services.sh
# Force a specific project to scope the services list
CLOUDSDK_CORE_PROJECT=my-project-id gcp/gcp_info_services.sh