Serverless (AWS Lambda)

A Nimbus app is a plain http.Handler (its router), so it can run on AWS Lambda with a thin adapter — no code changes to your routes. The serverless package converts Lambda proxy events to *http.Request and back, and nimbus make:lambda scaffolds the deployment.

Scaffold the target

# into an existing app
nimbus make:lambda

# or when creating a new app
nimbus new myapp --lambda

This writes three files: cmd/lambda/main.go (serves app.Router through the adapter), a SAM template.yaml (Lambda Function URL, provided.al2023, arm64), and a Makefile build rule.

The entry point

// cmd/lambda/main.go
func main() {
    app := bin.Boot()   // build the app: routes + middleware
    _ = app.Boot()      // run providers/plugins (no HTTP listener)
    lambda.Start(serverless.Lambda(app.Router))
}

The adapter supports API Gateway / Function URL payload v2.0 and v1.0 (REST API / ALB), base64 request & response bodies, and correct multi-cookie handling.

Deploy

nimbus install          # go mod tidy — pulls aws-lambda-go
sam build
sam deploy --guided

The Makefile cross-compiles a bootstrap binary for linux/arm64 with -tags lambda.norpc.

Serverless constraints

  • Use a database connection pooler (Supabase pooler, RDS Proxy, PgBouncer). Lambda concurrency × direct Postgres connections exhausts the server.
  • SQLite will not work — ephemeral filesystem + CGO. Set DB_DRIVER=postgres.
  • Set APP_ENV=production so boot doesn't auto-migrate on every cold start; run nimbus migrate from CI/CD.
  • Queue workers, the scheduler, and WebSocket/SSE need a long-running process — they don't run inside request-scoped invocations. Lambda serves the stateless HTTP subset.

Other edge targets

Cloudflare Workers can run Go only as WASM (via syumai/workers) and cannot use GORM/native TCP — bindings (D1/KV/R2) only, with WASM size limits; it's a constrained subset, not the full framework. Supabase Edge Functions run on Deno (TypeScript), not Go — author those in TS and call your Nimbus origin via @codesyncr/hive / @codesyncr/echo.