On AWS, I'm using Lambda function which receives event data and custom client context. For local testing, I want to run curl and invoke function with custom client context, defined as:
|
ClientContext string `json:"Client-Context"` |
I dug into codes, and found aws-lambda-rie seems not to add client context to a invoke payload:
|
invokePayload := &interop.Invoke{ |
|
ID: uuid.New().String(), |
|
InvokedFunctionArn: fmt.Sprintf("arn:aws:lambda:us-east-1:012345678912:function:%s", GetenvWithDefault("AWS_LAMBDA_FUNCTION_NAME", "test_function")), |
|
TraceID: r.Header.Get("X-Amzn-Trace-Id"), |
|
LambdaSegmentID: r.Header.Get("X-Amzn-Segment-Id"), |
|
Payload: bytes.NewReader(bodyBytes), |
|
CorrelationID: "invokeCorrelationID", |
|
} |
So, is there any ways to use custom client context with aws-lambda-rie? Should I send a pull request for this? It seems that Lambda-Runtime-Client-Context header is related to this, but I cannot find a way to use it properly.
Environment: I'm using aws-lambda-rie command in public.ecr.aws/lambda/nodejs:18.2022.12.02.19 image (https://gallery.ecr.aws/lambda/nodejs). Locally, I confirmed my function implementation can receive event data by running curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"payload":"hello world!"}', but cannot receive client context by adding Lambda-Runtime-Client-Context header like -H 'Lambda-Runtime-Client-Context: { "foo":"bar" }'. On AWS, my function can receive custom client context.
On AWS, I'm using Lambda function which receives event data and custom client context. For local testing, I want to run
curland invoke function with custom client context, defined as:aws-lambda-runtime-interface-emulator/lambda/core/directinvoke/customerheaders.go
Line 15 in 5a79e1e
I dug into codes, and found aws-lambda-rie seems not to add client context to a invoke payload:
aws-lambda-runtime-interface-emulator/cmd/aws-lambda-rie/handlers.go
Lines 96 to 103 in 5a79e1e
So, is there any ways to use custom client context with aws-lambda-rie? Should I send a pull request for this? It seems that
Lambda-Runtime-Client-Contextheader is related to this, but I cannot find a way to use it properly.Environment: I'm using
aws-lambda-riecommand inpublic.ecr.aws/lambda/nodejs:18.2022.12.02.19image (https://gallery.ecr.aws/lambda/nodejs). Locally, I confirmed my function implementation can receive event data by runningcurl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"payload":"hello world!"}', but cannot receive client context by addingLambda-Runtime-Client-Contextheader like-H 'Lambda-Runtime-Client-Context: { "foo":"bar" }'. On AWS, my function can receive custom client context.