Expand description
§S3 Pricing Library
A Rust library to calculate AWS S3 operation pricing dynamically using the AWS Pricing API.
§Features
- Storage pricing: Fetch storage costs per GB/month for any S3 storage class
- Request pricing: Get Class A (PUT, COPY, POST, LIST) and Class B (GET, etc.) request prices
- Data transfer: Calculate data transfer costs (to internet or cross-region)
- China regions: Support for AWS China regions (cn-north-1, cn-northwest-1) with CNY pricing
§Usage
ⓘ
use s3_pricing::S3PricingClient;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// For global AWS regions (USD pricing)
let client = S3PricingClient::new(None).await?;
let storage_price = client.get_storage_price("us-east-1", "STANDARD").await?;
println!("Storage: ${} per GB-Mo", storage_price);
// For AWS China regions (CNY pricing)
let china_client = S3PricingClient::new_china(None).await?;
let cn_storage = china_client.get_storage_price("cn-north-1", "STANDARD").await?;
println!("Storage: ¥{} per GB-Mo", cn_storage);
Ok(())
}§Supported Storage Classes
STANDARD- S3 StandardSTANDARD_IA- S3 Standard-Infrequent AccessONEZONE_IA- S3 One Zone-Infrequent AccessINTELLIGENT_TIERING- S3 Intelligent-TieringGLACIER/GLACIER_FLEXIBLE_RETRIEVAL- Amazon GlacierDEEP_ARCHIVE- Glacier Deep ArchiveGLACIER_IR/GLACIER_INSTANT_RETRIEVAL- Glacier Instant RetrievalEXPRESS_ONEZONE- S3 Express One ZoneREDUCED_REDUNDANCY- S3 Reduced Redundancy
§Supported Regions
- Global regions: All standard AWS regions (us-east-1, eu-west-1, etc.) - pricing in USD
- China regions: cn-north-1 (Beijing), cn-northwest-1 (Ningxia) - pricing in CNY
§Notes
- The global Pricing API is available in
us-east-1endpoint - The China Pricing API is available in
cn-northwest-1endpoint (api.pricing.cn-northwest-1.amazonaws.com.cn) - Credentials are resolved from the environment, shared config, or SSO profile
- Use
S3PricingClient::new()for global regions,S3PricingClient::new_china()for China regions