Amba

Deploy a Function

Ship a TypeScript function to Amba's edge runtime with `amba functions deploy` — versioned bundles, optional per-function rate limits, and rollback from the console.

amba functions deploy <file> bundles your handler and ships it to your project's edge runtime. Each deploy is its own version; rollouts are gradual with auto-rollback on a 5xx breach.

First deploy

amba functions deploy ./functions/hello.ts
✓ Bundled hello (24 KB)
✓ Deployed hello @ version v_abc123
  Live at https://<project>.fn.amba.host/hello

Hit it:

curl 'https://<project>.fn.amba.host/hello?name=amba'
{"greeting":"hello, amba"}

Flags

  • --name <name> — function name (default: filename without extension). The function is served at https://<project>.fn.amba.host/<name>.
  • --dry-run — bundle and report size without uploading. Useful for CI to fail when a function approaches the size cap.
  • --rate-limit-window <60s|5m|1h> — per-function rate-limit window.
  • --rate-limit-max <int> — max requests per window.
  • --rate-limit-key <user_id|ip> — bucket key for the rate limit (user_id reads the signed-in user from the session token; ip buckets by client IP).

All three rate-limit flags must be set together, or all omitted (no rate limit). The edge runtime enforces the limit pre-dispatch — the handler never runs for rate-limited requests.

Rate limit example

amba functions deploy ./functions/checkout.ts \
  --rate-limit-window 60s \
  --rate-limit-max 5 \
  --rate-limit-key user_id

That allows each signed-in user 5 requests per minute against /checkout. The 6th in a window returns 429 Too Many Requests from the edge without invoking the handler.

Reading secrets in production

process.env is populated from per-project secrets you set with the CLI:

amba secrets set STRIPE_API_KEY sk_live_...
amba secrets list

The handler reads them the same way it does locally:

const stripeKey = process.env.STRIPE_API_KEY;

Rollback

Every deploy is a new version with a unique id. The console's Rollouts view lists active versions in flight and offers a one-click rollback per version. The CLI also exposes:

amba functions logs <name> --tail   # watch error rate live

If a deploy regresses, ramp the previous version back to 100% from the console Rollouts page.

Watching logs

amba functions logs hello --tail
amba functions logs hello --since 2026-05-15T00:00:00Z --json | jq 'select(.level == "error")'

--tail (alias --follow) streams new log events as they arrive. --json emits one NDJSON event per line for piping into jq, log-shipping tools, or local analysis.

Common pitfalls

  • Bundle exceeds size capamba functions deploy --dry-run to see the bundle report. The heaviest deps are usually large NPM packages pulled in transitively; check the report for the top size contributors and prune.
  • Missing secret at runtime — confirm you ran amba secrets set for the project you deployed to. amba secrets list should show the name (values are never echoed).
  • First request slow — cold-starts hit after a long idle. The warm-path latency is much lower; in load tests, send a warming request before the burst.

Next

On this page