Thanks to visit codestin.com
Credit goes to lib.rs

#iam #postgresql #amazon-rds #aws #rds

aws-rds-signer

A Rust library for generating AWS IAM authentication tokens for Amazon RDS database connections

2 unstable releases

0.2.0 Mar 14, 2025
0.1.0 Mar 14, 2025

#7 in #amazon-rds

Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App

1,976 downloads per month

MIT license

20KB
174 lines

AWS RDS Signer

A Rust library for generating AWS IAM authentication tokens for Amazon RDS database connections. This library simplifies the process of authenticating to RDS instances using IAM roles and credentials.

Features

  • Generate IAM authentication tokens for RDS database connections
  • Support for custom expiration times
  • Automatic region detection from AWS configuration
  • Simple builder-style API
  • Async/await support
  • Zero dependencies on AWS SDK (uses lightweight AWS signature v4 implementation)

Installation

Add this to your Cargo.toml:

[dependencies]
aws-rds-signer = "0.1.0"

Usage

Here's a basic example of how to use the library:

use aws_rds_signer::Signer;
use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), aws_rds_signer::Error> {
    let mut signer = Signer::default();
    
    // Configure the signer
    signer
        .host("your-db-instance.region.rds.amazonaws.com".to_string())
        .port(5432)
        .user("your_db_user".to_string())
        .expires_in(Duration::from_secs(900)) // 15 minutes
        .region(Some("us-east-1".to_string())); // Optional, will use default region if not specified

    // Fetch the authentication token
    let token = signer.fetch_token().await?;
    
    // Use the token in your database connection string
    println!("Authentication token: {}", token);
    Ok(())
}

Configuration

The Signer struct supports the following configuration options:

  • host: The hostname of your RDS instance
  • port: The port number the database is listening on
  • user: The database username
  • expires_in: Token expiration duration (defaults to 900 seconds)
  • region: AWS region (optional, will use the region from your AWS configuration)

Requirements

  • Rust 2021 edition or later
  • AWS credentials configured in your environment (either through environment variables, AWS CLI configuration, or IAM role)
  • Appropriate IAM permissions to connect to your RDS instance

License

This project is licensed under the MIT License - see the LICENSE file for details.

Dependencies

~21MB
~299K SLoC