Skip to content

Add raw incoming invocation payload as header from lambda_http library #765

Closed as not planned
@kueckermann

Description

@kueckermann

We currently use the Lambda web adapter which makes use of lambda_http library to parse incoming requests. At the moment, this library only supports event payloads from a limited number of AWS sources. In our case we want to execute our application, which is running via the web adapter extension, directly from SQS. The reason for this is that we have some long running batch operations that need to be executed from SNS triggers. However, SNS has a hard cap on execution times. Seeing that these batches always overflow the execution time, we have had to send the batches to an SQS queue and pass them onto the private endpoint in our API. Creating a separate lambda to manage direct executions from SQS is out of scope for our small development team and a current solution is to create a separate lambda which formats and proxies the request onwards. This works, but is messy.

The request from SQS does come through to our application via the web adapter but it has a blank body, context, etc. From examining the code inside the adapter and the lambda_http library, it seems to be because lambda_http only knows how to parse the payload for a limited number of sources. I understand that parsing all AWS payload formats would be out of scope for this library, but rather what would be incredibly helpful would be if there was a reference stored somewhere to the original invocation payload.

At the moment, the request context and trace information are stored as headers. I'd like to recommend that the original payload be added as a header as well. If this is done, developers can utilise the web adapter to support invocations from any source by parsing the raw payload themselves from the header on the request and letting their own applications decide what to do with the invocation.

I'd recommend something along the lines of:
"x-amzn-request-payload": "..." which contains the raw payload.

Note that before the web adapter extension was released, many developers used @vendia/serverless-express to run web applications inside of lambda. serverless-express would allow requests from any source by letting the developer configuring how to manage the requests from those sources, so this kind of functionality is definitely not out of scope for what developers would want out of web adapter.

I'm creating this issue here, since the work to be done seems to be on the lambda_http library not on the web adapter extension. I'm not a rust dev so I could be wrong, but that's what I've understood from the code. If you think this is relevant to the web adapter repo, I'm happy to move this issue there.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions