Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to invoke a function with custom client context? #74

Open
nekketsuuu opened this issue Dec 5, 2022 · 4 comments · Fixed by #110
Open

How to invoke a function with custom client context? #74

nekketsuuu opened this issue Dec 5, 2022 · 4 comments · Fixed by #110

Comments

@nekketsuuu
Copy link

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.

@nekketsuuu
Copy link
Author

nekketsuuu commented Dec 14, 2022

I asked AWS Support and received an answer which says there is no ways to pass client context to my function, for now.

Alternatively, as a workaround, if it's possible to change function code, we can set client context in the code if no client context is given.

@valerena
Copy link
Contributor

valerena commented Apr 29, 2024

Still pending actual release with this feature. I'll keep it open until next release.

@valerena valerena reopened this Apr 29, 2024
@mcieno
Copy link
Contributor

mcieno commented Jun 5, 2024

@valerena when can we expect v1.19 to be available in public.ecr.aws/lambda/provided:al2 and public.ecr.aws/lambda/provided:al2023?

@valerena
Copy link
Contributor

valerena commented Jun 5, 2024

I reached out to the team in charge of maintaining those images. We'll see what they say

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants