ds-common-aws-rs-lib

Crates.iods-common-aws-rs-lib
lib.rsds-common-aws-rs-lib
version0.1.0
created_at2025-09-24 18:58:28.814039+00
updated_at2025-09-24 18:58:28.814039+00
descriptionA comprehensive Rust library for AWS services integration, providing high-level abstractions for AWS SDK operations with common utilities and error handling
homepage
repositoryhttps://github.com/grasp-labs/ds-common-aws-rs-lib
max_upload_size
id1853611
size124,507
(dsserviceuser)

documentation

https://docs.rs/ds-common-aws-rs-lib

README

DS Common AWS Rust Library

Crates.io version Documentation License: MIT OR Apache-2.0 Rust

A comprehensive Rust library for AWS services integration, providing high-level abstractions for AWS SDK operations with common utilities and error handling.

Features

  • Modular Design - Choose only the AWS services you need with feature flags
  • SSM Parameter Store - Simplified parameter retrieval and management
  • SQS Queue Service - Simplified queue operations and message handling
  • Unified Error Handling - Comprehensive error handling with AWS-specific error types
  • Async Support - Full async/await support for all operations
  • Type Safety - Strong typing for AWS operations and responses
  • Zero-cost Abstractions - High-level APIs with minimal overhead

Feature Flags

This crate supports the following features:

  • ssm - AWS Systems Manager Parameter Store support (enabled by default)
  • sqs - AWS Simple Queue Service support
  • full - Enables all features (equivalent to ssm + sqs)

Installation

[dependencies]
ds-common-aws-rs-lib = "0.1.0"

Or use cargo add:

cargo add ds-common-aws-rs-lib

Quick Start

Using the unified AWS service (recommended)

use aws_sdk_ssm::types::ParameterType;
use ds_common_aws_rs_lib::client::AwsClient;
use ds_common_aws_rs_lib::error::{Result, Error};

#[tokio::main]
async fn main() -> Result<(), Error> {
    // Create AWS service once with shared configuration
    let aws = AwsClient::new().await?;

    // Get specialized services (very fast, no network calls)
    let ssm = aws.ssm();
    let sqs = aws.sqs();

    // Use services with shared client
    let parameter = ssm.get_parameter("/myapp/database/url").await?;
    let queue_url = sqs.get_queue("my-queue").await?;
    sqs.send_message(&queue_url, "Hello, world!", None).await?;
    ssm.put_parameter("/myapp/database/url", "my-database-url", ParameterType::String, true).await?;
    Ok(())
}

Benefits of AwsClient

  • Single configuration load - Expensive credential resolution happens once
  • Fast service creation - No network calls when creating services
  • Shared connection pools - Better resource management
  • Easy extensibility - Simple to add S3, DynamoDB, etc.
  • Better performance - Reuse clients instead of creating new ones

API Reference

SSM Parameter Store

use ds_common_aws_rs_lib::client::AwsClient;
use aws_sdk_ssm::types::ParameterType;
use ds_common_aws_rs_lib::error::{Result, Error};

// Get a parameter
let aws = AwsClient::new().await?;
let ssm = aws.ssm();

let value = ssm.get_parameter("/myapp/database/url").await?;

// Put a parameter
ssm.put_parameter(
    "/myapp/database/url",
    "postgresql://localhost:5432/mydb",
    ParameterType::String,
    true
).await?;

SQS Queue Service

use ds_common_aws_rs_lib::client::AwsClient;
use ds_common_aws_rs_lib::sqs::SqsService;
use ds_common_aws_rs_lib::error::{Result, Error};

// Get queue URL
let aws = AwsClient::new().await?;
let sqs = aws.sqs();
let queue_url = sqs.get_queue("my-queue").await?;

// Send message with no delay
sqs.send_message(&queue_url, "Hello, world!", None).await?;

// Send message with 10 second delay
sqs.send_message(&queue_url, "Delayed message", Some(10)).await?;

Error Handling

The library provides unified error handling across all modules:

use ds_common_aws_rs_lib::error::{Result, Error};
use ds_common_aws_rs_lib::client::AwsClient;

// All functions return Result<T, Error>
async fn example() -> Result<(), Error> {
    // SSM errors are automatically converted to Error::Ssm
    let aws = AwsClient::new().await?;
    let ssm = aws.ssm();
    let sqs = aws.sqs();

    let param = ssm.get_parameter("/myapp/config").await?;
    let queue_url = sqs.get_queue("my-queue").await?;

    Ok(())
}

Supported Services

  • SSM Parameter Store - Secure parameter storage and retrieval
  • SQS Queue Service - Message queuing and processing
  • Unified Error Handling - Consistent error types across all services
  • Async Operations - Full async/await support for all AWS operations

License

This project is licensed under either of

at your option.

Commit count: 8

cargo fmt