Lambda Runtimes & the Factory
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.
One config type
Section titled “One config type”BaseLambdaConfig carries the shared surface, with a kind discriminant for the execution context:
kind | Context |
|---|---|
api | REST API handler (API Gateway v1) |
httpapi | HTTP API v2 handler (payload format v2, JWT authorizer) |
graphql | AppSync resolver |
worker | Background worker, stream/queue consumer, Cognito trigger |
cron | Scheduled EventBridge target |
edge | CloudFront Lambda@Edge |
authorizer | Custom 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
Runtimes
Section titled “Runtimes”runtime | Lambda runtime | Notes |
|---|---|---|
nodejs24 (default) | Node.js 24.x | Bundled with esbuild from a .ts entry point. |
nodejs22 | Node.js 22.x (LTS) | EOL April 2027. |
python312 · python311 · python310 · python39 | Python 3.x | Entry is a .py file; pip bundling supported. |
go | provided.al2023 | Entry is a package; builds a bootstrap binary. |
custom | provided.al2023 | Bring 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.
Defaults worth knowing
Section titled “Defaults worth knowing”- Architecture:
arm64(Graviton) — cheaper and faster for most workloads; override per-function witharchitecture: "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 acustomFunctionNamefactory hook for migrations. AconstructIdoverride exists for the same reason — see Logical-ID Permanence.
Environment tokens and permissions
Section titled “Environment tokens and permissions”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.
Adding handlers
Section titled “Adding handlers”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.