aws_utils_lambda
AWS Lambda utilities for Rust, providing a simplified interface for AWS Lambda operations.
Features
- Easy client creation with automatic credential handling
- Lambda function invocation with comprehensive parameter support
- Error handling with custom error types
- Re-exports
aws_sdk_lambdafor direct access to AWS SDK types
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Usage
Creating a Lambda Client
use aws_utils_lambda;
async
The client uses the AWS SDK's default credential chain for authentication:
- Environment variables if set
- ECS task role (for Fargate/ECS)
- EC2 instance profile
- AWS credentials file
- Other configured credential providers
Timeout Configuration
use ;
use Duration;
async
Logging AWS Communication
make_client accepts an optional [SharedInterceptor]. By passing an interceptor that
implements aws_sdk_lambda::config::Intercept, you can run custom logic — such as
logging — every time the client communicates with AWS.
The interceptor below logs each request, response, and operation result. It uses the
tracing crate, which is also what the AWS SDK uses
internally.
use make_client;
use ;
type BoxError = ;
;
# async
tracing does not emit anything until a subscriber is initialized. Set one up once in your
application (for example with tracing-subscriber) and control verbosity with RUST_LOG:
// Add `tracing-subscriber` to your dependencies.
fmt
.with_env_filter
.init;
Example output (RUST_LOG=info):
INFO LambdaLoggingInterceptor: Lambda -> AWS request method=POST uri=https://lambda.ap-northeast-1.amazonaws.com/
INFO LambdaLoggingInterceptor: AWS -> Lambda response status=200
INFO LambdaLoggingInterceptor: Lambda operation succeeded
Invoking Lambda Functions
use ;
use Blob;
async
Error Handling
The crate provides custom error types that wrap AWS SDK errors:
use Error;
match invoke.await
API Reference
Client Creation Functions
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>, interceptor: Option<SharedInterceptor>)- Creates a Lambda client with optional custom endpoint, timeout configuration, and interceptor (e.g. for logging)
Lambda Functions
lambda::invoke(client, function_name, client_context, invocation_type, log_type, payload, qualifier)- Invokes a Lambda function with comprehensive parameter support
Re-exports
The crate re-exports aws_sdk_lambda for direct access to AWS SDK types:
use ;
License
This project is licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.