Skip to content

Commit 186ddd2

Browse files
committed
feat: add AWS_LWA_PROXY_LAMBDA_RUNTIME_API to overwrite
AWS_LAMBDA_RUNTIME_API and use a proxy
1 parent 67a86f0 commit 186ddd2

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ The readiness check port/path and traffic port can be configured using environme
106106
| AWS_LWA_PASS_THROUGH_PATH | the path for receiving event payloads that are passed through from non-http triggers | "/events" |
107107
| AWS_LWA_AUTHORIZATION_SOURCE | a header name to be replaced to `Authorization` | None |
108108
| AWS_LWA_ERROR_STATUS_CODES | comma-separated list of HTTP status codes that will cause Lambda invocations to fail (e.g. "500,502-504,422") | None |
109+
| AWS_LWA_PROXY_LAMBDA_RUNTIME_API | overwrites `AWS_LAMBDA_RUNTIME_API` to allow proxying request (not affecting registration) | None |
109110

110111
> **Note:**
111112
> We use "AWS_LWA_" prefix to namespacing all environment variables used by Lambda Web Adapter. The original ones will be supported until we reach version 1.0.

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,13 @@ impl Adapter<HttpConnector, Body> {
310310
let compression = self.compression;
311311
let invoke_mode = self.invoke_mode;
312312

313+
if let Ok(runtime_proxy) = env::var("AWS_LWA_PROXY_LAMBDA_RUNTIME_API") {
314+
// overwrite the env variable since
315+
// LambdaInvokeMode::Buffered => lambda_http::run(svc).await,
316+
// calls the lambda lambda_runtime::run which doesn't allow to change the client URI
317+
env::set_var("AWS_LAMBDA_RUNTIME_API", runtime_proxy);
318+
}
319+
313320
if compression {
314321
let svc = ServiceBuilder::new().layer(CompressionLayer::new()).service(self);
315322
match invoke_mode {

0 commit comments

Comments
 (0)