Running Wasm Modules on AWS Lambda with Spin

Cloud Computing
Date:November 15, 2026
Topic:
Running Wasm Modules on AWS Lambda with Spin
⏱ 3 min read

AWS Lambda's native WebAssembly support is generally available, and it changes how we think about serverless. No more bundling a full Node.js or Python runtime just to run a 50KB function. You upload a `.wasm` file, Lambda executes it directly, and you pay for milliseconds instead of seconds. I tested this with Fermyon Spin, the fastest path from code to a production-ready Wasm module on Lambda.

Why Spin on Lambda?

Spin handles the heavy lifting: compiling Rust, Go, TypeScript, or Python to Wasm, generating the component model (WIT) interfaces, and packaging the artifact. Lambda's new runtime-agnostic model expects a WASI 0.2 component. Spin produces exactly that. The result? Cold starts under 5ms, memory footprints in megabytes, and zero runtime maintenance.

bash
# Install Spin
curl -fsSL https://developer.fermyon.com/downloads/install.sh | bash

# Create a new HTTP app (Rust example)
spin new http-rust my-api
cd my-api

# Build the Wasm component
spin build

# Deploy to Lambda (requires AWS CLI configured)
spin deploy --aws

The Deployment Flow

spin deploy --aws is a wrapper around the AWS SAM CLI. It creates a SAM template defining a AWS::Serverless::Function with Runtime: wasm32-wasi and Handler: bootstrap. The handler is a tiny shim Spin injects that translates Lambda events into WASI HTTP requests your component understands. You don't write this glue code.

MetricNode.js 20 (arm64)Spin Wasm (Rust)
Cold Start (p50)180 ms4 ms
Memory Baseline45 MB2 MB
Deployment Artifact12 MB (zip)350 KB (.wasm)
Max Concurrency (per 1GB)~22~500
💡
TipEnable SnapStart for the Wasm runtime in the console to pre-initialize the sandbox. Combined with Wasm's instant startup, you effectively eliminate cold latency for synchronous APIs.

Handling Events Beyond HTTP

Spin's trigger model maps Lambda event sources (SQS, S3, EventBridge, DynamoDB Streams) to component entry points. Define the trigger in spin.toml:

toml
[component.my-worker]
trigger = { type = "aws-sqs", queueArn = "arn:aws:sqs:us-east-1:123456789:my-queue" }
source = "target/wasm32-wasi/release/my_worker.wasm"
[component.my-worker.config]
max_batch_size = 10

The component receives a batch of records as a WASI `stdin` stream. Your Rust/Go/TS code reads JSON, processes, writes results to `stdout`. No SDK bloat.

Observability and Limits

Lambda emits standard logs and metrics to CloudWatch. Spin components can use `tracing` (Rust) or `otel` (Go/TS) to emit structured JSON logs that CloudWatch Insights parses natively. X-Ray tracing works via the Lambda extension API — add the aws-xray-sdk crate or library to your component.

⚠️
WarningCurrent limits: 10MB Wasm module size (compressed), 128MB–10GB memory, 15min max duration. WASI 0.2 sockets are not yet exposed — outbound HTTP requires the <code>wasi:http/outgoing-handler</code> import, which Spin provides via a built-in adapter.

Local Debugging Parity

spin up --aws runs a local Lambda emulator (RIE) with the same Wasm runtime. Attach your IDE debugger to port 9000. Set breakpoints in Rust println! or Go fmt.Println — they appear in the local console exactly as in CloudWatch. No "works on my machine" drift.

"

Wasm on Lambda isn't a science project anymore. It's the most cost-efficient way to run high-frequency, low-latency serverless workloads in 2026.

— Benchmarking WASI 0.2 runtimes, July 2026

Next Steps

Pick a high-invocation, low-complexity Lambda (webhook handler, queue consumer, auth validator). Rewrite it in Rust or Go with spin new. Deploy with spin deploy --aws. Compare the bill after two weeks. You'll likely cut compute costs 10x while dropping p99 latency below 10ms. That's the Wasm dividend — collect it.

Share𝕏 Twitterin LinkedInin Whatsapp