GC-301e · Module 2

Cross-Service Integration

3 min read

The real power of Gemini CLI with Google Cloud emerges when you orchestrate multiple services in a single conversation. A typical workflow: query BigQuery to identify underperforming regions, check Cloud Run service health in those regions, inspect Firestore for configuration issues, and draft a Cloud Monitoring alert policy. Each step feeds context into the next. Gemini maintains the thread — it remembers the BigQuery results when inspecting Cloud Run, and uses both when drafting the alert.

Cross-service workflows require careful credential scoping. Your identity needs permissions across all the services you are orchestrating. In local development, your Google account typically has broad access. In CI/CD, the service account must have roles for every service in the pipeline. The principle: map your workflows end-to-end before configuring IAM. If a pipeline touches Cloud Run, BigQuery, and Secret Manager, the service account needs roles for all three. Missing one role means the pipeline fails midway.

# Cross-service workflow via Gemini CLI:

# 1. Query BigQuery for error rates by region
# "Show me error rates by region for the last 24 hours"
bq query --use_legacy_sql=false \
  "SELECT region, COUNT(*) as errors FROM analytics.errors WHERE timestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 24 HOUR) GROUP BY region ORDER BY errors DESC"

# 2. Check Cloud Run health in the worst region
# "Check the Cloud Run service health in us-east1"
gcloud run services describe my-api --region us-east1 --format json
gcloud logging read "resource.type=cloud_run_revision AND severity>=ERROR" --limit 10

# 3. Check Firestore config for that region
# "Look at the region config document in Firestore"
gcloud firestore documents get projects/my-project/databases/\(default\)/documents/config/us-east1

# 4. Create a monitoring alert
# "Create a Cloud Monitoring alert for error rate > 5% in any region"
# Gemini generates the alert policy JSON and applies it