| Crates.io | aws_utils_lambda |
| lib.rs | aws_utils_lambda |
| version | 0.3.0 |
| created_at | 2025-07-17 05:06:38.463024+00 |
| updated_at | 2025-09-16 23:41:02.475529+00 |
| description | AWS Lambda utilities for Rust |
| homepage | https://github.com/UniqueVision/utilities.aws-utils |
| repository | https://github.com/UniqueVision/utilities.aws-utils |
| max_upload_size | |
| id | 1757092 |
| size | 69,038 |
AWS Lambda utilities for Rust, providing a simplified interface for AWS Lambda operations.
aws_sdk_lambda for direct access to AWS SDK typesAdd this to your Cargo.toml:
[dependencies]
aws_utils_lambda = "0.1.0"
use aws_utils_lambda;
#[tokio::main]
async fn main() {
// Create client with default timeout configuration
let client = aws_utils_lambda::make_client_with_timeout_default(None).await;
// Create client with custom endpoint (e.g., for LocalStack)
let client = aws_utils_lambda::make_client_with_timeout_default(Some("http://localhost:4566".to_string())).await;
}
The client uses the AWS SDK's default credential chain for authentication:
use aws_utils_lambda::{make_client, make_client_with_timeout, make_client_with_timeout_default};
use std::time::Duration;
#[tokio::main]
async fn main() {
// Use default timeout settings (recommended)
let client = make_client_with_timeout_default(None).await;
// Use custom timeout settings
let client = make_client_with_timeout(
None, // endpoint_url
Some(Duration::from_secs(3100)), // connect_timeout
Some(Duration::from_secs(60)), // operation_timeout
Some(Duration::from_secs(55)), // operation_attempt_timeout
Some(Duration::from_secs(50)), // read_timeout
).await;
// Use legacy client without timeout configuration
let client = make_client(None, None).await;
}
use aws_utils_lambda::{lambda, aws_sdk_lambda::types::{InvocationType, LogType}};
use aws_sdk_lambda::primitives::Blob;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = aws_utils_lambda::make_client_with_timeout_default(None).await;
// Simple invocation
let result = lambda::invoke(
&client,
Some("my-function"),
None, // client_context
None, // invocation_type (defaults to RequestResponse)
None, // log_type
Some(Blob::new(r#"{"key": "value"}"#)),
None, // qualifier
).await?;
// Async invocation
let result = lambda::invoke(
&client,
Some("my-function"),
None,
Some(InvocationType::Event),
Some(LogType::Tail),
Some(Blob::new(r#"{"key": "value"}"#)),
Some("$LATEST"),
).await?;
Ok(())
}
The crate provides custom error types that wrap AWS SDK errors:
use aws_utils_lambda::error::Error;
match lambda::invoke(&client, Some("my-function"), None, None, None, None, None).await {
Ok(output) => {
// Handle successful response
}
Err(Error::AwsSdk(e)) => {
// Handle AWS SDK errors
}
Err(Error::BuildError(e)) => {
// Handle build errors
}
Err(Error::ValidationError(msg)) => {
// Handle validation errors
}
}
make_client_with_timeout_default(endpoint_url: Option<String>) - Creates a Lambda client with default timeout settingsmake_client_with_timeout(endpoint_url, connect_timeout, operation_timeout, operation_attempt_timeout, read_timeout) - Creates a Lambda client with custom timeout settingsmake_client(endpoint_url: Option<String>, timeout_config: Option<TimeoutConfig>) - Creates a Lambda client with optional custom endpoint and timeout configurationlambda::invoke(client, function_name, client_context, invocation_type, log_type, payload, qualifier) - Invokes a Lambda function with comprehensive parameter supportThe crate re-exports aws_sdk_lambda for direct access to AWS SDK types:
use aws_utils_lambda::aws_sdk_lambda::{types::InvocationType, primitives::Blob};
This project is licensed under either of
at your option.
Contributions are welcome! Please feel free to submit a Pull Request.