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

Help: Is there a to (re)create the Lambda event JSON serialization from the Request<Body>? #717

Closed
bassmanitram opened this issue Nov 2, 2023 · 3 comments

Comments

@bassmanitram
Copy link
Contributor

bassmanitram commented Nov 2, 2023

The use case is a REST API integration Lambda function that modifies the request before passing onto another a Lambda function - but that second Lambda function can be run with or without the first - i.e. it too is written to accept REST API events.

@bassmanitram bassmanitram changed the title Help: Is there a to (re)create an HTTP Lambda request JSON serialization from the Request<Body>? Help: Is there a to (re)create the Lambda event JSON serialization from the Request<Body>? Nov 2, 2023
@greenwoodcm
Copy link
Contributor

there is not, today. is there a reason you want to directly invoke (with JSON) the second function? can you just call it via its REST frontend?

if not, i think your best bet is to not use lambda-http and instead use lambda-runtime directly. implement a handler that takes in the appropriate event type, for instance ApiGatewayV2httpRequest. you should be able to let the runtime deserialize that for you, modify the Rust struct as necessary, then serialize it back out to JSON for your downstream invoke.

@bassmanitram
Copy link
Contributor Author

It's actually a transitory need - eventually this Rust project will supercede our production Node implementation that enforces certain platform policies by being the first Lambda in an API call - in the case of node business APIs we can wrap the target Node handler. Now, with this, we can wrap Rust business API handlers. But the Node implementation also supports running as a separate Lambda function to invoke Business Lambda functions written for other runtimes. The Rust implementation must progress similarly, except that eventually the central lib will be used to wrap ANY target business Lambda without requiring a second Lambda function - that's the long term goal ... but we want this Rust "proxy" to replace the Node proxy completely ASAP (not least because it runs 200 times faster!), so for a certain time, it must, also, be able to invoke the target business lambda function.

That's probably far more than you wanted to know :)

Anyway, I solved the problem - https://gist.github.com/bassmanitram/3a22a0b98bfb59b5c5dad4be45888fb8

So we can close this.

Copy link

github-actions bot commented Nov 3, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for the maintainers of this repository to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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

No branches or pull requests

2 participants