Skip to content

Lambda Runtimes & the Factory

Open in ChatGPTOpen in Claude

Every Lambda in an Axis project — API route, GraphQL resolver, worker, cron target, edge function — is described by the same typed config and built by the same central factory in @axis-tech-co/axis-constructs. You declare what the function is; the factory handles bundling, wiring, IAM, logging, and tracing consistently.

BaseLambdaConfig carries the shared surface, with a kind discriminant for the execution context:

kindContext
apiREST API handler (API Gateway v1)
httpapiHTTP API v2 handler (payload format v2, JWT authorizer)
graphqlAppSync resolver
workerBackground worker, stream/queue consumer, Cognito trigger
cronScheduled EventBridge target
edgeCloudFront Lambda@Edge
authorizerCustom API authorizer
flowchart TD
  cfg["LambdaConfig (name · kind · entry · runtime · permissionsSpec · env)"] --> factory["Lambda factory"]
  factory --> dispatch["Runtime dispatch — Node · Python · Go builders"]
  factory --> tokens["Resolve {{token}} + ssm-path env vars via the registry"]
  factory --> iam["Build IAM policy statements from permissionsSpec"]
  factory --> logs["Log group + retention (30d dev / 90d prod)"]
  dispatch --> fn["IFunction — named appName-name-stageName"]
  tokens --> fn
  iam --> fn
  logs --> fn
runtimeLambda runtimeNotes
nodejs24 (default)Node.js 24.xBundled with esbuild from a .ts entry point.
nodejs22Node.js 22.x (LTS)EOL April 2027.
python312 · python311 · python310 · python39Python 3.xEntry is a .py file; pip bundling supported.
goprovided.al2023Entry is a package; builds a bootstrap binary.
customprovided.al2023Bring your own runtime via bundling config.

An unknown runtime string throws at synth with the supported list — never a silent fallback. Note the deliberate split from your dev machine: the toolchain runs on Node 22 (Install), while deployed functions default to nodejs24.

  • Architecture: arm64 (Graviton) — cheaper and faster for most workloads; override per-function with architecture: "x86_64". Lambda@Edge must be x86_64 and gets no environment variables or X-Ray — the factory enforces both.
  • Memory 512 MB, timeout 10 s — per-function overrides win over project-wide lambdaDefaults.
  • X-Ray tracing on by default (except edge).
  • Log retention: 30 days in dev, 90 in prod, overridable per function.
  • Function name: ${appName}-${name}-${stageName}, with a customFunctionName factory hook for migrations. A constructId override exists for the same reason — see Logical-ID Permanence.

Two pieces of factory plumbing remove the usual cross-stack boilerplate:

  • Environment resolution — env values can reference registry resources with {{token}} placeholders and SSM parameters with ssm-path syntax; the factory resolves both at synth, so a handler receives the real table name without you threading ARNs by hand.
  • permissionsSpec — a declarative permission list the factory turns into IAM policy statements, keeping each function’s access explicit at the config site — the explicit-over-implicit habit applied to IAM.

axs add lambda <module>/<name> --kind <kind> --runtime <runtime> generates the handler skeleton (Node index.ts + service.ts, Python handler.py, or Go main.go), the per-route config, a test stub, and the registry import — placed per your project’s layout (Layout).

© 2026 Axis Tech. Powered by axis-tech.co.