GCP API Gateway Expansion
Audit and action plan for expanding API Gateway route coverage across all backend services.
GCP API Gateway Expansion Plan
[!NOTE] Discussion: Open an issue to comment on this plan. Attach supporting documents to the issue or link them here.
Date: 2025-12-05 Status: Completed
Executive Summary
Full GCP infrastructure audit revealed several critical issues:
- API Gateway covers only ~30% of required endpoints
- crop-front-admin calls services directly, bypassing Gateway
- health-analytics-service is completely missing from Gateway
- Inconsistent IAM policies between services
Gateway Coverage Analysis
| Service | In Gateway | Total Routes | Coverage |
|---|---|---|---|
| search-service (public) | 7 | 9 | 78% |
| search-service (admin) | 3 | 14 | 21% |
| payment-service | 8 | 8 | 100% |
| health-analytics | 0 | 20+ | 0% |
| delivery-api | 0 | 5 | 0% |
Search-Service Admin Routes
In Gateway (3):
-
/api/admin/sync -
/api/admin/analyze-index -
/api/admin/debug-query
NOT in Gateway (11):
-
/api/admin/monitoring/overview -
/api/admin/monitoring/metrics -
/api/admin/monitoring/alerts -
/api/admin/monitoring/errors -
/api/admin/field-completeness -
/api/admin/validate-data -
/api/admin/index-document -
/api/admin/delete-by-query -
/api/admin/collections -
/api/admin/create-index -
/api/admin/parts
Health-Analytics Service Routes
NOT in Gateway (all):
-
/api/analytics/field-completeness -
/api/analytics/summary -
/api/analytics/environments -
/api/analytics/collections -
/api/health/media/coverage -
/api/health/media/gaps -
/api/health/media/distribution -
/api/health/media/dashboard/summary -
/api/health/media/dashboard/trend -
/api/health/media/dashboard/activity -
/api/health/media/dashboard/vendors -
/api/health/collections -
/api/health/vendors -
/api/health/vendors/:vendor/metrics -
/api/health/quality-distribution -
/api/admin/collections -
/api/admin/collections/:name -
/api/admin/collections/:name/query -
/api/admin/collections/:name/aggregate
Delivery-API Routes
NOT in Gateway (all):
-
/health -
/providers -
/rates(POST) -
/addresses/validate(POST) -
/shipments(GET/POST) -
/shipments/:tracking(GET/DELETE)
crop-front-admin Direct API Calls
Direct calls to search-service:
// lib/search-service.ts - baseURL = SEARCH_SERVICE_URL (direct Cloud Run)
/api/admin/monitoring/overview
/api/admin/monitoring/metrics
/api/admin/monitoring/alerts
/api/admin/monitoring/errors
/api/admin/field-completeness
/api/admin/validate-data
/api/admin/index-document
/api/admin/delete-by-query
/api/admin/syncDirect calls to health-analytics:
// lib/health-analytics-client.ts - baseURL = HEALTH_ANALYTICS_API_URL (direct Cloud Run)
/api/health/media/coverage
/api/health/media/gaps
/api/health/media/dashboard/summary
/api/health/media/dashboard/trend
/api/analytics/environments
/api/analytics/summary
/api/analytics/field-completenessAction Plan
Phase 1: Fix Critical Issues ✅ COMPLETED (2025-12-05)
- 1.1 Delete payment-service-staging (broken, not needed in dev)
- 1.2 Add API Gateway IAM to delivery-api
- 1.3 Add API Gateway IAM to health-analytics-service
Phase 2: Expand Gateway Configuration ✅ COMPLETED (2025-12-05)
- 2.1 Add search-service admin routes to gateway.yaml (11 routes)
- 2.2 Add health-analytics routes to gateway.yaml (19 routes)
- 2.3 Add delivery-api routes to gateway.yaml (8 operations)
Phase 3: Deploy Updated Gateway ✅ COMPLETED (2025-12-05)
- 3.1 Validate gateway.yaml
- 3.2 Create new API Gateway configuration (crop-api-v4)
- 3.3 Update gateway to new configuration
- 3.4 Test all endpoints via api.crop-dev.app
Phase 4: Migrate Frontend URLs ✅ COMPLETED (2025-12-05)
- 4.1 crop-front-admin: Update SEARCH_SERVICE_URL → api.crop-dev.app
- 4.2 crop-front-admin: Update HEALTH_ANALYTICS_API_URL → api.crop-dev.app
- 4.3 CROP-front: Already using api.crop-dev.app (no changes needed)
- 4.4 Added compatibility routes (/ready, /api/v1/health/analytics) to Gateway v5
Important: Delivery API URL format:
# Correct (with prefix for Gateway routes):
DELIVERY_API_URL=https://api.crop-dev.app/api/v1/delivery
# Wrong (missing prefix - will get 404 on /rates, /shipments etc):
DELIVERY_API_URL=https://api.crop-dev.appRollback Plan
# Rollback Gateway to previous version
gcloud api-gateway gateways update crop-gateway \
--location=us-east1 \
--api=crop-api \
--api-config=crop-api-v3 # previous versionRelated
- GCP Infrastructure — current Cloud Run services and Gateway configuration