Skip to content

aws-lambda-dev

aws-lambda-dev is a CLI for iterating on an existing AWS Lambda function from your machine. Point it at a Node.js handler and a function name, and it rebuilds, uploads, and optionally invokes the function every time you save.

npx aws-lambda-dev watch dev
[dev] watch: Watching src/**/*.ts
[dev] watch: Change detected /home/me/orders/src/handler.ts
[dev] build: Building src/handler.ts
[dev] build: Created /home/me/orders/.lambda-dev/dev/function.zip (48211 bytes, 112 ms)
[dev] deploy: Uploading to my-existing-lambda-dev
[dev] deploy: Uploaded my-existing-lambda-dev version $LATEST
[dev] invoke: Payload { path: '/health' }
[dev] invoke: status 200, version $LATEST, logs available, payload { ok: true }

What it does

Each deploy cycle runs the same steps, in order:

  1. Load and validate lambda-dev.yml. Invalid config stops here, before anything touches AWS.
  2. Build the handler with esbuild into index.js, then zip it with its sourcemap and any extra files you list.
  3. Snapshot the function's current code and environment, the first time you deploy to it, so rollback can restore it later.
  4. Sync environment variables, if the target defines any. Only the variables you list are changed; everything else on the function is left alone. See Environment variables.
  5. Upload the zip with UpdateFunctionCode.
  6. Invoke the function with a test payload, if requested.

watch repeats that cycle on file changes, debouncing rapid saves and never running two deploys for the same target at once.

What it doesn't do

  • It doesn't create, delete, or reconfigure Lambda functions (other than environment variables you opt into). Create the function with your usual tooling first.
  • It doesn't run your function locally. Code runs in real Lambda, with its real IAM role, VPC, and layers.
  • It doesn't publish versions or move aliases. Uploads update $LATEST.

Use it on development functions

Every save replaces the function's code. Point it at a function you own for development, never at production.

Next steps

  • Getting started: install, create a config, and deploy for the first time.
  • Configuration: every option in lambda-dev.yml.
  • Commands: CLI reference.
  • Rollback: put a function back as it was before your first deploy.
  • Checks: verify a deploy by invoking it with known events and comparing the responses.