You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bridge the Lambda SnapStart lifecycle to the inner web application. Because the
adapter runs the app as a separate process, the app has no access to the
snapshot boundary; two optional HTTP hooks give it one.
- AWS_LWA_SNAPSTART_BEFORE_CHECKPOINT_PATH: POSTed before the snapshot so the app
can drain resources that will not survive it.
- AWS_LWA_SNAPSTART_AFTER_RESTORE_PATH: POSTed after restore so the app can
reconnect, refresh credentials, reseed randomness and regenerate per-environment
identifiers.
Both are opt-in and independent. A non-2xx response or a connection failure fails
the corresponding SnapStart phase rather than serving traffic against an
improperly prepared application. Each hook waits for the readiness check first, so
AWS_LWA_ASYNC_INIT cannot let a hook fire before the app is listening.
After restore the adapter also rebuilds its own HTTP client, so no connection
captured in the snapshot is reused, and re-runs the readiness check before traffic
is admitted.
The hook paths are control-plane routes, so external requests that resolve to one
receive 403. The guard canonicalizes both sides through the same Url::set_path
transformation and compares segment lists, so alternate spellings -- percent
encoding, encoded slashes, matrix parameters, dot segments, case, repeated slashes
-- are blocked too. A hook path the guard cannot cover exactly (not
canonicalizable, decoding to a literal %, collapsing to the app root, or colliding
with AWS_LWA_PASS_THROUGH_PATH) fails initialization instead of running with a
partially protected route.
Connection pooling is disabled for the pre-snapshot client because CLOCK_MONOTONIC
does not advance across the snapshot gap, which makes hyper's idle accounting
unreliable for entries pooled before it (hyper#3810, rust-lang/rust#79462). The
client rebuilt after restore pools normally, since it holds no pre-boundary
entries -- that is what makes the new AWS_LWA_POOL_IDLE_TIMEOUT_SECONDS effective
on the invocations that serve traffic.
Also adds AWS_LWA_READINESS_CHECK_TIMEOUT_SECONDS to bound the readiness wait at
cold start and after restore, bumps lambda_http to 1.3.0 for the SnapStart
lifecycle APIs, fixes AWS_LWA_REMOVE_BASE_PATH to strip exactly one leading
occurrence on a segment boundary, and ships deployable FastAPI examples for both
zip and container packaging.
Validated on a deployed SnapStart container function: both hooks fire, the 403
guard blocks the full equivalence class through API Gateway while distinct routes
still 404, post-restore idle reuse works, the after-restore reseed yields distinct
per-environment identifiers, and graceful-shutdown SIGTERM still arrives on
restored environments.
| AWS_LWA_READINESS_CHECK_HEALTHY_STATUS | HTTP status codes considered healthy (e.g., "200-399") | "100-499" |
61
62
| AWS_LWA_ASYNC_INIT | enable asynchronous initialization for long initialization functions | "false" |
62
-
| AWS_LWA_REMOVE_BASE_PATH |the base path to be removed from request path| None |
63
+
| AWS_LWA_REMOVE_BASE_PATH | base path to remove from the request path; strips exactly one leading occurrence on a segment boundary (with `/api`: `/api/api/order`->`/api/order`, `/apiorder` unchanged; trailing slash normalized)| None |
63
64
| AWS_LWA_ENABLE_COMPRESSION | enable gzip/br compression for response body (buffered mode only) | "false" |
64
65
| AWS_LWA_INVOKE_MODE | Lambda function invoke mode: "buffered" or "response_stream" | "buffered" |
65
66
| AWS_LWA_PASS_THROUGH_PATH | the path for receiving event payloads from non-http triggers | "/events" |
66
67
| AWS_LWA_AUTHORIZATION_SOURCE | a header name to be replaced to `Authorization`| None |
67
68
| AWS_LWA_ERROR_STATUS_CODES | HTTP status codes that will cause Lambda invocations to fail (e.g. "500,502-504") | None |
| AWS_LWA_SNAPSTART_BEFORE_CHECKPOINT_PATH | inner-app path the adapter POSTs to before a SnapStart snapshot (drain resources) | None |
71
+
| AWS_LWA_SNAPSTART_AFTER_RESTORE_PATH | inner-app path the adapter POSTs to after a SnapStart restore (reconnect/reseed) | None |
72
+
| AWS_LWA_POOL_IDLE_TIMEOUT_SECONDS | idle keep-alive (seconds) for the adapter's connection to your app | "4" |
73
+
| AWS_LWA_READINESS_CHECK_TIMEOUT_SECONDS | seconds (fractional allowed, e.g. 0.5) to wait for the app to report ready (cold-start init and after a SnapStart restore); on expiry the adapter FAILS (init fails and the runtime never starts; a restore fails) rather than serving. Unset, 0, or negative all mean wait indefinitely (a set-but-<=0 or malformed value is ignored with a warning). async_init keeps its own ~9.8s bound | unset / <=0 (unbounded) |
69
74
70
75
> **Deprecation Notice:** The following non-namespaced environment variables are deprecated and will be removed in version 2.0:
|`AWS_LWA_REMOVE_BASE_PATH`| Base path to remove from request path | None |
15
+
|`AWS_LWA_REMOVE_BASE_PATH`| Base path to remove from the request path. Strips **exactly one** leading occurrence and only on a path-segment boundary: with `/api`, `/api/api/order` → `/api/order` and `/apiorder` is passed through unchanged; a configured trailing slash (`/api/`) is normalized.| None |
|`AWS_LWA_INVOKE_MODE`| Invoke mode: `buffered` or `response_stream`|`buffered`|
18
18
|`AWS_LWA_PASS_THROUGH_PATH`| Path for non-HTTP event payloads |`/events`|
19
19
|`AWS_LWA_AUTHORIZATION_SOURCE`| Header name to replace with `Authorization`| None |
20
20
|`AWS_LWA_ERROR_STATUS_CODES`| HTTP status codes that cause Lambda invocation failure (e.g. `500,502-504`) | None |
21
21
|`AWS_LWA_LAMBDA_RUNTIME_API_PROXY`| Proxy URL for Lambda Runtime API requests | None |
22
+
|`AWS_LWA_SNAPSTART_BEFORE_CHECKPOINT_PATH`| Inner-app path the adapter POSTs to before a SnapStart snapshot | None |
23
+
|`AWS_LWA_SNAPSTART_AFTER_RESTORE_PATH`| Inner-app path the adapter POSTs to after a SnapStart restore | None |
24
+
|`AWS_LWA_POOL_IDLE_TIMEOUT_SECONDS`| Idle keep-alive (seconds) for the adapter's connection to your app |`4`|
25
+
|`AWS_LWA_READINESS_CHECK_TIMEOUT_SECONDS`| Seconds (fractional allowed, e.g. `0.5`) the adapter waits for the app to report ready (cold-start init **and** after a SnapStart restore). On expiry the adapter **fails** rather than serving: cold-start init fails (the runtime never starts) and a restore fails. Unset, `0`, or a negative value all mean **wait indefinitely** (no bound); a set-but-`<= 0` or malformed value is ignored with a `warn!`. The `async_init` path keeps its own ~9.8s bound (non-fatal) and is unaffected. | unset / `<= 0` (unbounded) |
0 commit comments