llm-shield-cloud
Cloud abstraction layer for LLM Shield providing unified traits for AWS, GCP, and Azure integrations.
Overview
This crate provides trait-based abstractions for cloud services, enabling LLM Shield to leverage cloud-native features while maintaining portability across providers.
Features
- Secret Management: Unified
CloudSecretManagertrait for AWS Secrets Manager, GCP Secret Manager, and Azure Key Vault - Object Storage:
CloudStoragetrait for AWS S3, GCP Cloud Storage, and Azure Blob Storage - Observability:
CloudMetrics,CloudLogger, andCloudTracertraits for cloud-native monitoring - Configuration: Type-safe configuration structures for all cloud providers
- Caching: Built-in secret caching with TTL support
- Error Handling: Unified error types across all cloud operations
Architecture
┌────────────────────────────────────┐
│ LLM Shield Application │
└────────────────────────────────────┘
│
▼
┌────────────────────────────────────┐
│ llm-shield-cloud (traits) │
│ - CloudSecretManager │
│ - CloudStorage │
│ - CloudMetrics/Logger/Tracer │
└────────────────────────────────────┘
│ │ │
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ AWS │ │ GCP │ │ Azure │
│ Provider │ │ Provider │ │ Provider │
└──────────┘ └──────────┘ └──────────┘
Usage
Basic Example
use ;
async
Secret Caching
use SecretCache;
use Duration;
let cache = new; // 5 minute TTL
// Set a secret in cache
cache.set.await;
// Get from cache (returns None if expired)
if let Some = cache.get.await
Storage Operations
use ;
async
Configuration
Cloud integrations are configured via CloudConfig:
cloud:
provider: aws # or gcp, azure, none
aws:
region: us-east-1
secrets_manager:
enabled: true
cache_ttl_seconds: 300
s3:
bucket: llm-shield-models
models_prefix: models/
results_prefix: scan-results/
cloudwatch:
enabled: true
namespace: LLMShield
log_group: /llm-shield/api
Providers
Concrete implementations are provided by separate crates:
llm-shield-cloud-aws: AWS integrations (Secrets Manager, S3, CloudWatch, X-Ray)llm-shield-cloud-gcp: GCP integrations (Secret Manager, Cloud Storage, Cloud Logging, Cloud Trace)llm-shield-cloud-azure: Azure integrations (Key Vault, Blob Storage, Azure Monitor, App Insights)
Enable provider-specific features in your Cargo.toml:
[]
= "0.1"
= { = "0.1", = true }
[]
= ["llm-shield-cloud-aws"]
Error Handling
All cloud operations return Result<T, CloudError>:
use ;
match secret_manager.get_secret.await
Testing
Run tests:
Run tests with output:
Performance
- Caching: Built-in secret caching reduces API calls by >90%
- Async: All operations are fully async with tokio
- Zero-cost abstractions: Trait-based design adds <5% overhead
Security
- Zero plain-text secrets in code or configuration
- Automatic credential rotation support
- Constant-time comparison for sensitive data
- Comprehensive audit logging
License
MIT OR Apache-2.0