-
Notifications
You must be signed in to change notification settings - Fork 16
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
Provide an adaptor for localstack deployment #574
Comments
for completion, this is what a Lambda GET invocation via HTTP API Gateway looks like (irrelevant fields omitted):
|
this is also the event how it looks like using localstack
|
Note locally I could fix it by unzipping the generated zip, and add / fix some lines in the generated index.js For example adding my custom handler for localstack specifics (or what seems specific , although all docs I found about AWS suppose that the event match the same as the one generated by localstack...)
For some other issues (more related to the secretsmanager related code that read a secret, where it fails due to "UnrecognizedClientException" possible exception in the context of localstack
|
Expected Behaviour
Deployment of the generated zip should be compatible with localstack development (which allow to run AWS locally)
Actual Behaviour
Current "lambda" handler is not working while running in localstack due to few differences in the event object structure.
It returns a message like "Request with GET/HEAD method cannot have body" for a simple GET request.
Reproduce Scenario (including but not limited to)
a bit complex, you need to use localstack in docker, and setup a few services (api gateway, s3, secresmanager etc.. as it would run in a real AWS)
define a bootstrap script in test/aws/apigateway.sh (you will also need some for s3 and secretsmanager) but that one is the most important
Steps to Reproduce
Once you setup to make the generated zip (dist/helix-services/[email protected]) as the lambda function to be used by the apigateway endpoint of your choice. Call the service url .i.e http://localhost:4566/restapis/hrbmpo1ifh/dev/_user_request_/endpoint, it will returns a 500 with "Request with GET/HEAD method cannot have body"
Platform and Version
AWS via Localstack
Sample Code that illustrates the problem
Logs taken while reproducing problem
The main reason seems that the main function expect some specific structure for the requestContent, which is not 100% the same in the localstack
main differences is that there is no event.requestContent.http.method, instead it is under event.requestContent.httpMethod
and second main differences is that event.body = "" instead of being null in case of "GET" request.
one fix could be to create a small adapter that fix the event object to be like the default "lambda" adapter expect (mainly copy what is needed under event.requestContext.http and fix the body value to be null in get of "GET|HEAD" request.
The text was updated successfully, but these errors were encountered: