DocsDiscoveryGCP Discovery

GCP Discovery

Discover and inventory your Google Cloud Platform infrastructure including compute instances, databases, networking, and serverless services.


Overview

The GCP collector connects to one Google Cloud project with a service account key and discovers about 45 resource types across compute, containers, databases, storage, serverless, networking, data, security, DevOps and monitoring services, then links them using network and load-balancing references. Discovery is scoped to a single project per zone.

Connection Configuration

To configure a GCP discovery zone, provide the project ID and the service account credentials JSON.

  • project_id (required): The GCP project ID (not the project number). Found in Google Cloud Console > Project Settings.
  • credentials_json (required): The full JSON content of a service account key file. Generate this from Google Cloud Console > IAM & Admin > Service Accounts > Keys > Add Key > Create New Key (JSON).

Note: Create one zone per project. Optional connection_config keys, settable through the API: regions (limit the regional scan) and resource_types (subset of the supported types). A credentials_file path or the server's Application Default Credentials are accepted only when DISCOVERY_ALLOW_SERVER_CREDENTIALS is enabled on the server; otherwise credentials_json is required.

Discovered Resource Types

The GCP collector discovers resources across compute, data, networking, container, and serverless services.

  • Compute: instances, instance groups, instance templates, disks, snapshots, images, machine images, reservations
  • Containers: GKE clusters
  • Databases: Cloud SQL, Spanner, Bigtable, Memorystore for Redis and Memcached
  • Storage: Cloud Storage buckets, Filestore
  • Serverless: Cloud Functions, Cloud Run, App Engine, Cloud Scheduler, Cloud Tasks
  • Networking: VPC networks and subnetworks, load balancers (forwarding rules), backend services, health checks, firewall rules, routes, Cloud Routers, VPN gateways and tunnels, Cloud NAT, SSL certificates, Cloud DNS
  • Messaging and data: Pub/Sub topics and subscriptions, BigQuery datasets, Dataproc clusters, Dataflow jobs
  • Security and DevOps: Secret Manager secrets, KMS key rings, Cloud Armor policies, Artifact Registry, Cloud Build triggers, service accounts
  • Monitoring: logging sinks, alert policies

Dependency Detection

The GCP collector creates these dependencies from resource references:

  • Compute instances use their VPC network
  • GKE clusters use their VPC network and subnetwork
  • Firewall rules are attached to their VPC network; routes, Cloud Routers and VPN gateways belong to their network
  • VPN tunnels use their VPN gateway and depend on their Cloud Router
  • Forwarding rules load-balance to their backend service and use their network; backend services depend on their health checks

Required Permissions

AsPeekIt requires a GCP service account with the Viewer role (roles/viewer) at the project level. This built-in role grants read-only access to all resources in the project. For a more restrictive setup, you can create a custom role with only the specific permissions needed.

  • 1. Go to Google Cloud Console > IAM & Admin > Service Accounts
  • 2. Click "Create Service Account" and name it (e.g., "idp-discovery")
  • 3. Grant the "Viewer" role at the project level
  • 4. Create a JSON key for the service account and download it
  • 5. Paste the full JSON key content into the credentials_json field in AsPeekIt

Warning: Never grant Editor, Owner, or any write role to the AsPeekIt service account. The Viewer role is sufficient for all discovery operations. Store the JSON key securely and avoid sharing it outside of AsPeekIt.

# Using gcloud CLI to create the service account and assign the Viewer role
gcloud iam service-accounts create idp-discovery \
  --display-name="AsPeekIt Discovery" \
  --project=<your-project-id>

gcloud projects add-iam-policy-binding <your-project-id> \
  --member="serviceAccount:idp-discovery@<your-project-id>.iam.gserviceaccount.com" \
  --role="roles/viewer"

gcloud iam service-accounts keys create idp-discovery-key.json \
  --iam-account=idp-discovery@<your-project-id>.iam.gserviceaccount.com

Tips and Best Practices

Consider these recommendations when setting up GCP discovery.

  • Use a dedicated service account for AsPeekIt and do not share it with other tools
  • Rotate service account keys periodically and update the credentials in the zone configuration
  • For organizations using Google Cloud Organization, consider creating a custom role at the org level and granting it on each project
  • A discovery interval of 60 minutes is suitable for most GCP projects
  • If the project uses Shared VPC, ensure the service account also has Viewer access on the host project for complete network topology