Lambda

A Lambda function whose role can only write logs until you grant more. Graviton, one-year log retention and IAM-only function URLs by default.

Compute · anvil:aws:Lambda

Choosing a runtime

Set runtime and point handler at your code. Anvil builds the code before every anvil deploy. Everything else about the function (the least-privilege role, the log group, grants and hatch) is the same whichever runtime you pick.

runtimeWrite it inhandler
nodejs22+TypeScript or JavaScript on Node.js 22 or newerfunctions/api/index.handler
rustRust, built with cargo‑lambdafunctions/api

Every runtime runs on arm64 (Graviton) unless you set architecture: 'x86_64'.

Node.js

Node.js 22 and newer: set runtime to nodejs24.x (recommended) or nodejs22.x. The handler is the entry file without its extension, plus the name of the function it exports. Omit handler to deploy a blank placeholder that returns 200.

const api = new anvil.aws.Lambda('api', {
  runtime: 'nodejs24.x',
  handler: 'functions/api/index.handler',
});
api = anvil.aws.Lambda("api",
    runtime="nodejs24.x",
    handler="functions/api/index.handler",
)
api, err := anvilaws.NewLambda(ctx.PulumiCtx(), "api", &anvilaws.LambdaArgs{
    Runtime: anvilaws.LambdaRuntime_Nodejs24_x,
    Handler: pulumi.String("functions/api/index.handler"),
})
if err != nil {
    return err
}
// functions/api/index.ts
export const handler = async (event: unknown) => {
  return { statusCode: 200, body: JSON.stringify({ ok: true }) };
};

How it's built

  • One file. esbuild bundles the entry and everything it imports into a single index.js, so no node_modules ships. Prefer pure-JS packages: native addons can't be bundled.
  • TypeScript without a compile step. esbuild strips types but doesn't check them, so run tsc --noEmit in CI to catch type errors.
  • Skipped when nothing changed. A function is rebuilt only when a file in its entry's folder changes. anvil deploy --force-cache skips the build and reuses the last one.