| Crates.io | llm-shield-cloud |
| lib.rs | llm-shield-cloud |
| version | 0.1.1 |
| created_at | 2025-11-03 02:49:27.528738+00 |
| updated_at | 2025-11-03 03:49:50.659534+00 |
| description | Cloud abstraction layer for LLM Shield - unified traits for AWS, GCP, and Azure |
| homepage | |
| repository | https://github.com/llm-shield/llm-shield-rs |
| max_upload_size | |
| id | 1913815 |
| size | 142,277 |
Cloud abstraction layer for LLM Shield providing unified traits for AWS, GCP, and Azure integrations.
This crate provides trait-based abstractions for cloud services, enabling LLM Shield to leverage cloud-native features while maintaining portability across providers.
CloudSecretManager trait for AWS Secrets Manager, GCP Secret Manager, and Azure Key VaultCloudStorage trait for AWS S3, GCP Cloud Storage, and Azure Blob StorageCloudMetrics, CloudLogger, and CloudTracer traits for cloud-native monitoring┌────────────────────────────────────┐
│ LLM Shield Application │
└────────────────────────────────────┘
│
▼
┌────────────────────────────────────┐
│ llm-shield-cloud (traits) │
│ - CloudSecretManager │
│ - CloudStorage │
│ - CloudMetrics/Logger/Tracer │
└────────────────────────────────────┘
│ │ │
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ AWS │ │ GCP │ │ Azure │
│ Provider │ │ Provider │ │ Provider │
└──────────┘ └──────────┘ └──────────┘
use llm_shield_cloud::{CloudSecretManager, SecretValue, Result};
async fn load_api_keys(
secret_manager: &dyn CloudSecretManager
) -> Result<Vec<String>> {
// Fetch API keys from cloud secret manager
let secret = secret_manager.get_secret("llm-shield/api-keys").await?;
// Parse the secret value
let api_keys: Vec<String> = serde_json::from_str(secret.as_string())?;
Ok(api_keys)
}
use llm_shield_cloud::SecretCache;
use std::time::Duration;
let cache = SecretCache::new(300); // 5 minute TTL
// Set a secret in cache
cache.set("my-key".to_string(), secret_value).await;
// Get from cache (returns None if expired)
if let Some(value) = cache.get("my-key").await {
println!("Cache hit!");
}
use llm_shield_cloud::{CloudStorage, PutObjectOptions};
async fn upload_model(storage: &dyn CloudStorage) -> Result<()> {
let model_data = tokio::fs::read("model.onnx").await?;
let options = PutObjectOptions {
content_type: Some("application/octet-stream".to_string()),
storage_class: Some("STANDARD".to_string()),
..Default::default()
};
storage.put_object_with_options(
"models/toxicity.onnx",
&model_data,
&options
).await?;
Ok(())
}
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
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:
[dependencies]
llm-shield-cloud = "0.1"
llm-shield-cloud-aws = { version = "0.1", optional = true }
[features]
cloud-aws = ["llm-shield-cloud-aws"]
All cloud operations return Result<T, CloudError>:
use llm_shield_cloud::{CloudError, Result};
match secret_manager.get_secret("my-secret").await {
Ok(value) => println!("Secret: {}", value.as_string()),
Err(CloudError::SecretNotFound(name)) => {
eprintln!("Secret not found: {}", name);
}
Err(e) => {
eprintln!("Failed to fetch secret: {}", e);
}
}
Run tests:
cargo test -p llm-shield-cloud
Run tests with output:
cargo test -p llm-shield-cloud -- --nocapture
MIT OR Apache-2.0