Expand description
§Armature Lambda
AWS Lambda runtime adapter for Armature applications.
This crate allows you to deploy Armature applications to AWS Lambda with API Gateway, ALB, or Lambda Function URLs.
§Quick Start
ⓘ
use armature::prelude::*;
use armature_lambda::LambdaRuntime;
#[controller("/")]
struct HelloController;
#[controller_impl]
impl HelloController {
#[get("/")]
async fn hello() -> &'static str {
"Hello from Lambda!"
}
}
#[module(controllers: [HelloController])]
struct AppModule;
#[tokio::main]
async fn main() -> Result<(), lambda_runtime::Error> {
// Initialize tracing for CloudWatch
armature_lambda::init_tracing();
// Create Armature application
let app = Application::create::<AppModule>();
// Run on Lambda
LambdaRuntime::new(app).run().await
}§With AWS Services
ⓘ
use armature_lambda::LambdaRuntime;
use armature_aws::{AwsServices, AwsConfig};
#[tokio::main]
async fn main() -> Result<(), lambda_runtime::Error> {
armature_lambda::init_tracing();
// Initialize AWS services
let aws = AwsServices::new(
AwsConfig::from_env()
.enable_dynamodb()
.enable_s3()
.build()
).await?;
// Register in DI container
let app = Application::create::<AppModule>();
app.container().register(aws);
LambdaRuntime::new(app).run().await
}§Deployment
Build for Lambda with:
# Install cargo-lambda
cargo install cargo-lambda
# Build for Lambda
cargo lambda build --release
# Deploy
cargo lambda deployRe-exports§
pub use lambda_http;pub use lambda_runtime;
Macros§
- impl_
request_ handler - Macro to implement RequestHandler for Armature applications.
Structs§
- Lambda
Config - Lambda runtime configuration.
- Lambda
Request - Wrapper for Lambda HTTP requests.
- Lambda
Response - Lambda HTTP response.
- Lambda
Runtime - Lambda runtime for Armature applications.
Enums§
- Lambda
Error - Lambda runtime errors.
Functions§
- init_
tracing - Initialize tracing for Lambda/CloudWatch.
- init_
tracing_ with_ level - Initialize tracing with a custom log level.
Type Aliases§
- Result
- Result type for Lambda operations.