llm-shield-cloud-gcp
GCP cloud integrations for LLM Shield - Secret Manager, Cloud Storage, Cloud Monitoring, and Cloud Logging.
Overview
Production-ready GCP implementations of cloud abstraction traits:
- GCP Secret Manager - Secure secret storage with automatic caching
- GCP Cloud Storage - Object storage for models and results
- GCP Cloud Monitoring - Application metrics and monitoring
- GCP Cloud Logging - Structured logging and log aggregation
Installation
[]
= "0.1"
= "0.1"
= { = "1.35", = ["full"] }
Quick Start
Secret Manager
use GcpSecretManager;
use CloudSecretManager;
async
Cloud Storage
use GcpCloudStorage;
use CloudStorage;
async
Cloud Monitoring
use GcpCloudMonitoring;
use ;
use HashMap;
async
Cloud Logging
use GcpCloudLogging;
use ;
async
Configuration
cloud:
provider: gcp
gcp:
project_id: my-project-id
secret_manager:
enabled: true
cache_ttl_seconds: 300
storage:
bucket: llm-shield-models
models_prefix: models/
monitoring:
enabled: true
logging:
enabled: true
log_name: llm-shield-api
GCP Credentials
Uses Application Default Credentials (ADC):
- GOOGLE_APPLICATION_CREDENTIALS environment variable
- gcloud auth application-default login credentials
- Service account on GCE/GKE
- Workload Identity for GKE pods
Development Setup
# Install gcloud CLI
|
# Authenticate
# Set project
Production (Service Account)
# Create service account
# Grant permissions (use custom role)
# Create key
# Set environment variable
GKE Workload Identity
# Enable Workload Identity on cluster
# Create Kubernetes service account
# Bind to GCP service account
# Annotate Kubernetes service account
Use in pod:
apiVersion: v1
kind: Pod
metadata:
name: llm-shield-api
spec:
serviceAccountName: llm-shield-ksa
containers:
- name: api
image: llm-shield:latest
IAM Permissions
See iam-roles/ for custom role definitions:
secret-manager-role.yaml- Secret Manager permissionsstorage-role.yaml- Cloud Storage permissionsmonitoring-role.yaml- Monitoring and Logging permissionsllm-shield-full-role.yaml- All permissions (dev/test)
Creating Custom Roles
# Create custom role
# Assign to service account
Testing
Unit Tests
Integration Tests
Performance
| Operation | Throughput | Latency (p50) |
|---|---|---|
| Secret fetch (cached) | 100,000/s | <1ms |
| Secret fetch (uncached) | 1,000/s | ~50ms |
| GCS upload (1MB) | 50 MB/s | ~20ms |
| GCS upload (50MB resumable) | 80 MB/s | ~625ms |
| Metrics export (batch) | 1,000/s | ~10ms |
| Logs export (batch) | 10,000/s | ~5ms |
Cost Estimates
Monthly costs (production):
| Service | Usage | Cost |
|---|---|---|
| Secret Manager | 10 secrets, 100K ops | ~$3 |
| Cloud Storage | 100 GB, 1M ops | ~$3 |
| Cloud Logging | 50 GB ingested | ~$25 |
| Cloud Monitoring | 50 metrics | ~$8 |
| Total | ~$39/month |
Security Best Practices
- Use Workload Identity for GKE (no service account keys)
- Apply least-privilege IAM roles
- Enable audit logging for all services
- Rotate service account keys regularly
- Use customer-managed encryption keys (CMEK)
- Set bucket lifecycle policies
- Enable VPC Service Controls
Troubleshooting
Authentication Errors
# Check current authentication
# Check ADC
# Verify project
Permission Errors
# List IAM policy for service account
# Test Secret Manager access
# Test Cloud Storage access
License
MIT OR Apache-2.0
Related Crates
llm-shield-cloud- Cloud abstraction traitsllm-shield-cloud-aws- AWS integrationsllm-shield-cloud-azure- Azure integrations