Text Analyzer Service

A simple AWS Lambda service written in Rust that analyzes text and returns word frequency statistics.

Local Development

# 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!"}'

Building for AWS Lambda

# Install cargo-lambda
brew install cargo-lambda/tap/cargo-lambda

# Build the Lambda function
cargo lambda build --release

AWS Deployment Steps

  1. Create an AWS Lambda function:

    • Runtime: Custom runtime on Amazon Linux 2
    • Architecture: x86_64
    • Handler: (not needed for custom runtime)
  2. 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
  3. Create API Gateway:

    • Create a REST API
    • Create a POST method on /analyze
    • Configure Lambda integration
    • Deploy to a stage
  4. 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!"}'