Lambda Web Functions
Lambda Web Functions provide an AWS-shaped control plane for publishing Node.js web code and attaching HTTP endpoints to it. The system stores immutable function revisions and endpoint routes, starts Docker-backed environments on demand, and forwards endpoint traffic as ordinary HTTP with platform limits and errors.
Service model
Lambda Web Functions join deployment state with an HTTP data plane. The control plane manages a function, its immutable revisions, and its named endpoints. The data plane uses endpoint domains to find a revision and serve the request. The service uses the Lambda API surface at /2025-03-07 and shares Lambda's signing identity.
This diagram shows how a deployment becomes an HTTP response.
flowchart LR
A[Create or update function] --> B[Store revision]
B --> C[Route endpoint to revision]
C --> D[Match endpoint domain]
D --> E[Authorize and rate check]
E --> F[Choose revision by weight]
F --> G[Acquire Docker environment]
G --> H[Forward HTTP request]
H --> I[Stream HTTP response]
For the wider Lambda execution model, see Lambda execution platform. Shared IAM behavior is described in IAM and authentication. CloudFormation provisioning is described in CloudFormation, and shared request behavior is described in request routing and protocols.
Control plane
Function resources
The function is the stored owner for revisions, endpoints, tags, and the resource policy. It is scoped by account and home region, and its ARN identifies the web-function resource rather than a normal Lambda function.
The control plane supports creation, lookup, listing, deletion, tags, account settings, and resource-policy operations. Revision and endpoint lists use request-bound page tokens, so a token cannot be reused with different list parameters.
References: src/…/LambdaWebService.java• L304-423 src/…/LambdaWebService.java• L1167-1296
Revision state
A revision is an immutable snapshot of S3 code and the settings needed to run it. It includes the Node.js runtime, execution role, timeout, per-environment concurrency, environment values, and logging settings. The current service accepts the nodejs24.x runtime and checks that the execution role can be assumed by Lambda.
When a revision is created, the service checks access to the selected S3 object and copies that object into revision-owned code storage. The revision keeps the resolved object version even when the request did not name one. Later changes to the S3 object do not change what that revision runs. Invalid or oversized code creates a stored Failed revision instead of a deployable snapshot. The failed revision remains available for inspection but cannot receive endpoint traffic.
An endpoint in LatestRevision mode moves all traffic to a new usable revision. An endpoint with explicit weights stays on its configured revisions. When an active revision raises the revision count above the reported quota, unused older revisions are cleaned up. A revision cannot be deleted while an endpoint routes to it.
References: src/…/WebFunctionRevision.java• L8-43 src/…/LambdaWebService.java• L432-455 src/…/LambdaWebService.java• L569-709 src/…/LambdaWebExecutionRole.java• L27-51 src/…/LambdaWebEnvironmentManager.java• L728-747
Endpoint state
An endpoint is a named HTTP entry point that maps a domain to one or two revisions. It carries the endpoint type, regions, access mode, deployment mode, revision weights, environment limit, and request rate limit. Its access mode selects either application-managed access or IAM authorization.
The endpoint types express the intended region scope:
| Endpoint type | Domain and routing role |
|---|---|
HomeRegion | One domain in the function's home region |
MultiRegion | One global domain for the endpoint |
PerRegion | A domain for each listed region |
LatestRevision is available only for HomeRegion endpoints and assigns all traffic to the newest usable revision. Disabled mode requires explicit weights whose total is 100. The service records multi-region domains and selects a serving region for the global route.
An endpoint created from a failed revision remains Failed and is not invokable. Requests to that endpoint receive a 409 Platform.EndpointNotActive response. Create responses show child revisions and endpoints as Pending, even though stored reads settle to Active when activation succeeds. An update response shows updateStatus: InProgress; a later read reports Successful. Input shape errors are collected into one AWS-shaped validation response before resource work starts.
References: src/…/LambdaWebService.java• L800-916 src/…/LambdaWebService.java• L931-1113 src/…/LambdaWebValidation.java• L11-14
Resource policy state
The function resource policy controls which callers can invoke protected endpoints. Put and delete operations use a policy revision ID for optimistic concurrency, so a caller must update the policy that it last read.
The service keeps a normalized AWS-shaped policy document and renders it for reads. It supplies the default policy version when it is absent, preserves the supported statement order, writes single values in compact form, and returns account principals as IAM root ARNs for the active partition. This keeps policy responses stable while retaining the access rules used by IAM authorization.
References: src/…/LambdaWebPolicyText.java• L22-80 src/…/LambdaWebService.java• L1410-1444
Execution role state
The execution role connects revision configuration to the permissions available inside an environment. Revision creation checks the role's partition, account, identity, and trust policy before it stores a runnable revision. Environment startup checks the role again with the function ARN and account as source context.
This two-stage check keeps invalid role configuration out of normal deployment while still handling a role that changes or disappears before a request starts.
References: src/…/LambdaWebExecutionRole.java• L27-51 src/…/LambdaWebService.java• L569-590 src/…/LambdaWebEnvironmentManager.java• L551-572
Execution environments
Docker environment lifecycle
Each endpoint and serving region owns a pool of Docker environments for its selected revisions. A request reuses an environment with capacity or starts one when no suitable environment has room. The environment loads the revision-owned ZIP into /var/task and starts a Node.js HTTP server on the Lambda Web port.
The environment receives Lambda-style metadata, account and region values, user variables, and temporary execution credentials. The metadata service gives the environment its availability zone through a token-bound endpoint. Its API address is shared by environments, but each environment has its own bearer token. The metadata path returns the zone for a valid token, rejects an invalid token, and follows the platform's path redirect behavior. The server must listen within about 9 seconds. An idle environment is stopped after the configured Lambda container idle period, and a process that exits between requests is replaced on the next request.
References: src/…/LambdaWebEnvironmentManager.java• L551-647 src/…/LambdaWebEnvironmentManager.java• L703-713 src/…/LambdaWebMetadataServer.java• L29-35 src/…/LambdaWebMetadataServer.java• L62-141
Environment capacity
An environment accepts up to the revision's maxConcurrencyPerEnvironment active requests. The pool chooses the least busy suitable environment, starts another when all are full, and can replace an idle environment from another revision when maxEnvironments has been reached.
This separates two kinds of overload. maxEnvironments limits the number of live environments, while rateLimit limits admission before environment selection. When no idle environment can be replaced, the request receives an environment throttle response.
References: src/…/LambdaWebEnvironmentManager.java• L312-383 src/…/LambdaWebDataPlane.java• L206-267
Environment startup and exit state
Environment startup is a readiness gate rather than a simple container launch. The platform loads the code, starts the Node.js server, checks that it listens on the configured HTTP port, and records startup failures before the environment can serve traffic.
If the process exits before a request reaches it, the next request can use a new environment. If it exits during an exchange, the current request fails instead of running twice. The environment also reports start, request, use, exit, and shutdown events to the platform log.
References: src/…/LambdaWebEnvironmentManager.java• L777-824 src/…/LambdaWebEnvironmentManager.java• L894-1012 src/…/LambdaWebDataPlane.java• L270-364
HTTP data plane
Endpoint routing
The data plane claims requests whose Host matches a domain minted for a Lambda Web endpoint. It resolves that host to the owning account, home region, function, endpoint, and serving region. It then performs endpoint-state, access, and admission checks before it selects a revision from the endpoint weights and acquires an environment.
The endpoint state must be active before routing can continue. A domain that identifies a failed endpoint returns a 409 platform response. A host that has Lambda Web's shape but was not minted by the service receives the platform's invalid-endpoint page rather than reaching another service.
The domain includes the emulator host and port. A client can call it directly or send the domain in the Host header to the local listener. Only GET, HEAD, POST, PUT, PATCH, OPTIONS, and DELETE are accepted. The request body is streamed to the application, and a body without Content-Length uses chunked transfer encoding.
This sequence shows the request checks before application code runs.
sequenceDiagram
participant Client
participant Edge as Lambda Web edge
participant Store as Endpoint state
participant Pool as Environment pool
participant App as Node.js server
Client->>Edge: HTTP/1.1 request with Host
Edge->>Store: Resolve endpoint domain
Store-->>Edge: Account, region, endpoint, weights
Edge->>Edge: Apply endpoint state and method checks
Edge->>Edge: Apply access and rate checks
Edge->>Edge: Select revision
Edge->>Pool: Acquire capacity
Pool-->>Edge: Reused or new environment
Edge->>App: Forward request
App-->>Edge: Status, headers, streamed body
Edge-->>Client: HTTP response
References: src/…/LambdaWebService.java• L213-290 src/…/LambdaWebDataPlane.java• L149-228 src/…/LambdaWebDataPlane.java• L511-524
IAM authorization
IamAuth endpoints require a fresh AWS Signature Version 4 or Signature Version 4A request for the Lambda service in the serving region. A presigned request is also accepted. The request must also be allowed to perform lambda:InvokeWebFunctionEndpoint on the endpoint resource. With IAM enforcement enabled, the decision uses the caller's policies and the function resource policy while preserving same-account and cross-account rules.
CloudFront-origin requests use an internal signature that identifies the distribution. With IAM enforcement enabled, the function resource policy makes the final service-principal decision. Direct callers use SigV4 or SigV4a and the normal caller and resource policy rules.
The authorization check happens before rate limiting and before environment selection. The signature and security headers never reach the application. An unsigned or unauthorized request receives a forbidden response without consuming a request token.
References: src/…/LambdaWebIamAuth.java• L43-52 src/…/LambdaWebIamAuth.java• L107-149 src/…/LambdaWebIamAuth.java• L152-191 src/…/LambdaWebDataPlane.java• L182-203
HTTP header contract
The edge preserves application headers while setting the endpoint context that the application needs. It adds a request ID, endpoint name, forwarded scheme and port, and the client address. It removes hop-by-hop headers, method-override headers, client-supplied Lambda Web headers, and AWS signing headers that could expose platform credentials.
Responses keep the application status, body, and safe headers. The edge adds the request ID and log-stream headers, removes connection and trailer headers, and streams the body as the application writes it.
References: src/…/LambdaWebDataPlane.java• L563-615 src/…/LambdaWebDataPlane.java• L366-395
Request timeout
The revision's timeoutSeconds bounds the full exchange. If no response has started by the deadline, the edge returns a 504 platform page. If a response is already streaming, the edge cuts the connection. A slow upload reaches the same deadline after the full request body arrives.
References: src/…/LambdaWebDataPlane.java• L270-318 src/…/LambdaWebDataPlane.java• L366-395
Response and error shaping
Application responses
The data plane passes through the application's status and response body instead of converting the result to a Lambda invocation payload. This makes a Lambda Web endpoint behave like an HTTP origin while still exposing Lambda Web request and log context.
An application that fails during a request produces a 503 origin-request error. A process that fails before it listens produces a 502 startup error, and the next request can start a fresh environment. Startup classification distinguishes a listen timeout, an initialization or import failure, and a clean or failed runtime exit.
References: src/…/LambdaWebDataPlane.java• L318-364 src/…/LambdaWebDataPlane.java• L366-395 src/…/LambdaWebEnvironmentManager.java• L777-824
Control plane responses
The control plane renders functions, revisions, and endpoints as stable JSON resource shapes. Create and update operations can return a transitional view without changing the stored state that later reads expose.
Control-plane errors use JSON rather than the endpoint's HTML error pages. Access denials use a 403 response with an AWS AccessDeniedException header and a Message field. Unexpected control-plane failures use a 500 InternalServerException header and an empty object body.
References: src/…/LambdaWebService.java• L292-299 src/…/LambdaWebAccessDeniedException.java• L5-15 src/…/LambdaWebInternalServerException.java• L5-15 src/…/LambdaWebErrorBodyExceptionMapper.java• L8-17
Platform error pages
Platform failures use AWS-shaped HTML pages with a request ID and lambda-web-error-type. The edge has separate pages for malformed requests and oversized headers. The error type tells the caller whether the edge rejected the request, the endpoint was unavailable, or the application environment failed.
| Status | Error type | Trigger |
|---|---|---|
| 400 | Platform.MalformedRequest | Unsupported HTTP method |
| 409 | Platform.EndpointNotActive | Endpoint is in Failed state |
| 431 | Platform.HeaderTooLarge | Lambda Web request headers exceed the edge limit |
| 403 | None | IAM authentication or authorization fails |
| 404 | Platform.InvalidEndpoint | Unknown minted-looking endpoint host |
| 429 | Platform.EndpointMaxEnvThrottle | Environment capacity is full |
| 429 | Platform.EndpointRequestThrottle | Endpoint request rate is exceeded |
| 502 | Platform.CannotAssumeRole, Application.TimeoutListenError, Application.InitCodeError, Runtime.ImportCodeError, Runtime.Exit, or Runtime.ExitError | Role assumption fails or an environment does not listen, fails during startup, or exits before serving |
| 503 | Platform.EndpointDisabled | Endpoint rate limit is zero |
| 503 | Runtime.OriginRequestError | Application process fails during a request |
| 504 | Runtime.RequestTimeout | Revision timeout expires |
| 505 | Platform.UnsupportedHttpVersion | HTTP/1.0 request |
References: src/…/LambdaWebErrorPages.java• L8-40 src/…/LambdaWebDataPlane.java• L149-183 src/…/LambdaWebDataPlane.java• L638-692
Rate limiting
Endpoint request limits
An endpoint rateLimit uses one token bucket per endpoint creation and serving region. The bucket starts full at one second of capacity and refills at the configured rate, so a short burst can pass while a sustained rate above the limit is rejected. Buckets that are untouched for a second are discarded. A rate of zero disables the endpoint and returns 503.
The bucket key includes the account, serving region, and endpoint domain. A recreated endpoint therefore starts with new rate state. The bucket is separate from environment capacity. A request can pass the rate check and still receive EndpointMaxEnvThrottle when all allowed environments are busy or the endpoint has reached its environment limit. IAM authorization runs before this bucket for IAM-authorized endpoints.
References: src/…/LambdaWebDataPlane.java• L176-237 src/…/LambdaWebRateLimiter.java• L9-67 src/…/LambdaWebService.java• L1098-1113
Observability
Application logs
Application output becomes CloudWatch Logs events for the environment. Each non-blank line from standard output or standard error becomes an event, while incomplete output is emitted when the environment ends. Large lines are split at the log event limit and invalid UTF-8 is replaced so the log stream remains readable.
References: src/…/LambdaWebEnvironmentManager.java• L894-963 src/…/LambdaWebLogs.java• L79-148
Platform logs
Platform logs describe environment startup, invocation, request completion, periodic use, and shutdown. They provide request IDs, endpoint identity, result data, duration, response size, concurrency, CPU time, and peak memory. Request and environment events are kept separate from application output. The configured system log level controls which platform events are visible.
References: src/…/LambdaWebEnvironmentManager.java• L598-647 src/…/LambdaWebEnvironmentManager.java• L976-1012 src/…/LambdaWebLogs.java• L109-125
CloudWatch metrics
CloudWatch metrics summarize request outcomes and environment use for each function and endpoint. The service records executed requests, HTTP status classes, request throttles, active environments, and environment resource use. A bounded background publisher keeps metric storage off the request path, so a full queue can drop metrics without blocking application traffic.
References: src/…/LambdaWebMetrics.java• L27-39 src/…/LambdaWebMetrics.java• L76-118 src/…/LambdaWebMetrics.java• L163-193 src/…/LambdaWebDataPlane.java• L398-436
Log destinations
The service writes each environment's events to a local companion log group and to a region-qualified stream in the configured log group. It creates missing groups and streams when the first event arrives. A bounded queue protects the running application from a slow log service; dropped events are reported by a later platform.logsDropped event when the system log level allows warnings.
References: src/…/LambdaWebLogs.java• L25-59 src/…/LambdaWebLogs.java• L127-213
CloudFormation integration
Resource lifecycle
CloudFormation can manage AWS::Lambda::WebFunction, AWS::Lambda::WebFunctionRevision, and AWS::Lambda::WebFunctionEndpoint. A function is the parent resource, a revision is a deployable snapshot, and an endpoint is the stable HTTP identity.
Function and revision changes follow replacement rules. Every revision property is create-only, so a changed revision creates a new snapshot and removes the old one after the update commits. An endpoint keeps its identity when its name, function, type, and region set stay the same; changes to those identity fields require replacement.
CloudFormation endpoints use explicit RevisionWeights; the resource schema does not expose AutoDeploymentMode. A revision should expose its ID through Fn::GetAtt so an endpoint can follow a replacement revision. In-place endpoint and tag changes keep rollback snapshots so a failed stack update can restore the prior values.
References: src/…/LambdaWebCfnProvisioner.java• L26-31 src/…/LambdaWebCfnProvisioner.java• L132-225 src/…/CloudFormationLambdaWebIntegrationTest.java• L70-99
Change checklist
When these files or sections are changed, remember to consider these:
- Keep revision immutability aligned across S3 code lookup, endpoint weights, environment pool keys, and revision deletion checks.
- Keep revision-owned code copies aligned with revision creation, deletion, reload cleanup, and Docker extraction. A stale or missing copy can make a valid revision fail only when it first receives traffic.
- Keep resolved S3 object versions aligned across revision storage, response rendering, and Docker extraction. A request without a version must still run the version captured at creation.
- Keep execution-role trust checks aligned between revision validation and environment startup. A role can pass the first check and fail before an environment starts.
- Keep failed revision and endpoint state aligned with endpoint creation, stored response views, route admission, and the 409 error page.
- Keep endpoint domain indexes aligned with endpoint create, update, delete, persistence reload, and endpoint recreation. A stale domain can route traffic to the wrong lifecycle.
- Keep the control-plane transitional response view separate from stored
ActiveandSuccessfulstate. Waiters depend on this difference. - Keep resource-policy normalization, policy revision checks, account-principal rendering, and IAM policy evaluation aligned. A policy can look correct in reads but authorize the wrong caller if these views diverge.
- Keep control-plane exception mapping aligned with each JSON error body. Access denial and internal failure use different body fields and must not leak into the HTTP data-plane error shape.
- Keep weighted routing,
LatestRevisionupdates, and CloudFormationRevisionWeightsbehavior aligned so deployment updates do not silently change traffic. - Keep IAM signature validation, policy evaluation, reserved-header removal, and rate-limit admission in the same order. An authorization change can affect both security and throttle behavior.
- Keep rate-limit admission and environment-capacity admission separate. They represent different 429 error types and must preserve their order.
- Keep Docker startup, metadata-token registration, readiness probing, exit watching, idle cleanup, and request retry behavior aligned. A process that exits before a request must not produce the same result as one that dies during a request.
- Keep metadata token cleanup aligned with environment shutdown and failed startup. A stale token must not expose an old environment's zone.
- Keep request and response header filtering aligned with timeout, streaming, and body-transfer behavior. Changes can alter the application-visible HTTP contract.
- Keep endpoint identity rules aligned with CloudFormation replacement and rollback behavior.
- Keep output framing, log queue limits, platform log levels, and CloudWatch destination creation aligned. A change can alter both application logs and platform metrics.
- Keep request outcome accounting aligned with platform request-complete events and CloudWatch status and throttle metrics. A change in when an exchange finishes can create mismatched observability data.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| An endpoint domain is not indexed after reload or creation | A valid endpoint returns Platform.InvalidEndpoint | Rebuild and update the domain index with endpoint state |
| A revision is deleted while an endpoint still routes to it | Existing traffic loses its selected target | Reject deletion until all endpoint weights move away |
| A failed revision is attached to an endpoint | Clients receive traffic from an endpoint that cannot start | Keep the endpoint failed and reject invocation with Platform.EndpointNotActive |
LatestRevision and explicit weights are accepted together | A new revision can override an intended traffic split | Reject weights when automatic latest-revision routing is active |
| An execution role passes deployment validation but fails the startup trust check | Requests receive Platform.CannotAssumeRole and no environment serves traffic | Check the role with the function source context before container creation |
| IAM authorization is skipped or runs after rate admission | Unauthorized traffic can reach the app or consume endpoint tokens | Verify the signature and policy decision before the rate bucket |
| The endpoint rate limit is checked after environment acquisition | Rejected traffic can consume Docker capacity | Apply the request bucket before revision and environment selection |
| A container exits before readiness | Clients see a generic origin failure instead of a startup error | Classify listen timeout, init failure, import failure, and early exit as startup pages |
| A container dies while serving a request | The client can receive a partial or misleading success | Finish the exchange once and return Runtime.OriginRequestError when no response has started |
A response continues past timeoutSeconds | A stream can run beyond the revision contract | Cancel the exchange and close an already-started response at the deadline |
| The Lambda Web metric queue is full | Request and environment metrics are dropped while traffic continues | Keep metric publication off the request path and treat the queue as best effort |
Client-supplied lambda-web-* or method-override headers pass through | The application can receive forged platform context or a changed method | Drop reserved and hop-by-hop request headers before forwarding |
| A metadata token remains after an environment is gone | A later caller can use stale credentials to query environment metadata | Remove tokens on failed startup, shutdown, and environment discard |
| Log output is split without preserving partial UTF-8 or final lines | CloudWatch receives unreadable or missing application events | Decode across Docker frames and flush each stream when it ends |
| Log delivery blocks the Docker output reader | The application can stop writing while logs are sent | Queue events and deliver them on separate writers with a bounded backlog |
| A CloudFormation revision update mutates the old revision | Existing endpoint traffic changes without a stable replacement | Treat revision properties as create-only and clean up the old snapshot after commit |
| An empty S3 code object reaches revision storage | The control plane returns an internal error instead of a deployable revision | Map the failure to InternalServerException with the JSON control-plane shape |
Key files
| File | Why to read it |
|---|---|
| src/…/LambdaWebService.java | Function, revision, endpoint, routing index, persistence, validation, and policy control plane |
| src/…/LambdaWebController.java | REST JSON operations and resource-level API boundaries |
| src/…/LambdaWebCode.java | Revision-owned code snapshots and cleanup after resource changes |
| src/…/WebFunctionRevision.java | Immutable code version and runtime state represented by a revision |
| src/…/WebFunctionEndpoint.java | Endpoint identity, regions, weights, scaling, and failed state |
| src/…/LambdaWebResponses.java | Stored and transitional control-plane response views |
| src/…/LambdaWebPolicyText.java | AWS-shaped storage and read rendering for function resource policies |
| src/…/LambdaWebErrorBodyExceptionMapper.java | JSON shape for access-denied and unexpected control-plane failures |
| src/…/LambdaWebValidation.java | AWS-shaped collection of input validation errors |
| src/…/LambdaWebExecutionRole.java | Execution-role trust checks for deployment and startup |
| src/…/LambdaWebDataPlane.java | Host routing, IAM admission, HTTP forwarding, streaming, timeout, and response handling |
| src/…/LambdaWebIamAuth.java | Signature validation and IAM policy decisions for protected endpoints |
| src/…/LambdaWebEnvironmentManager.java | Docker environment startup, readiness, reuse, capacity, exit handling, and idle cleanup |
| src/…/LambdaWebMetadataServer.java | Token-bound environment metadata access |
| src/…/LambdaWebRateLimiter.java | Per-endpoint burst and refill behavior |
| src/…/LambdaWebErrorPages.java | Platform status, error types, and HTML response shapes |
| src/…/LambdaWebLogs.java | CloudWatch destinations, queueing, and dropped-log reporting |
| src/…/LambdaWebOutputLines.java | Conversion of container output into log events |
| src/…/LambdaWebPlatformLog.java | Environment lifecycle and request metric events |
| src/…/LambdaWebMetrics.java | CloudWatch request, throttle, status, and environment metrics |
| src/…/LambdaWebCfnProvisioner.java | CloudFormation replacement, update, and rollback rules |