A simple AWS Lambda service written in Rust that analyzes text and returns word frequency statistics.
# Run locally
cargo run
# Run tests
cargo test
# Test with curl (in another terminal)
curl -X POST http://localhost:3000/analyze \
-H "Content-Type: application/json" \
-d '{"text": "Hello world! This is a test. Hello again!"}'# Install cargo-lambda
brew install cargo-lambda/tap/cargo-lambda
# Build the Lambda function
cargo lambda build --release-
Create an AWS Lambda function:
- Runtime: Custom runtime on Amazon Linux 2
- Architecture: x86_64
- Handler: (not needed for custom runtime)
-
Deploy the function:
# Deploy using cargo-lambda (requires AWS credentials configured) cargo lambda deploy --iam-role arn:aws:iam::YOUR_ACCOUNT_ID:role/lambda-role -
Create API Gateway:
- Create a REST API
- Create a POST method on
/analyze - Configure Lambda integration
- Deploy to a stage
-
Test the deployed function:
curl -X POST https://YOUR_API_ID.execute-api.REGION.amazonaws.com/STAGE/analyze \ -H "Content-Type: application/json" \ -d '{"text": "Hello AWS Lambda!"}'