Skip to main content

Crate s3_pricing

Crate s3_pricing 

Source
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 Standard
  • STANDARD_IA - S3 Standard-Infrequent Access
  • ONEZONE_IA - S3 One Zone-Infrequent Access
  • INTELLIGENT_TIERING - S3 Intelligent-Tiering
  • GLACIER / GLACIER_FLEXIBLE_RETRIEVAL - Amazon Glacier
  • DEEP_ARCHIVE - Glacier Deep Archive
  • GLACIER_IR / GLACIER_INSTANT_RETRIEVAL - Glacier Instant Retrieval
  • EXPRESS_ONEZONE - S3 Express One Zone
  • REDUCED_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-1 endpoint
  • The China Pricing API is available in cn-northwest-1 endpoint (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

Modules§

s3_pricing_client