micronaut-aws icon indicating copy to clipboard operation
micronaut-aws copied to clipboard

Support for AWS Gateway HTTP API

Open msandy10 opened this issue 5 years ago • 5 comments

Hi Team, We are thinking to migrate our lambda invocation from AWS Gateway REST API to AWS Gateway HTTP API to save some money(70% costs saving) and low latency

does Micronauts micronaut-function-aws-api-proxy support AWS Gateway HTTP API invocation?

Environment Information

  • AWS: Lambda with GraalVM and AWS Gateway Http API
  • GraalVM: 19.2.0.1
  • Micronaut Version: 1.3.4

We have created AWS HTTP API Route and mapped lambda endpoint with the route but we are getting following error message:

2020-06-09T12:34:27.046+05:30 | START RequestId: d73e1527-0a04-4a3a-98f2-1f078c2e76b6 Version: $LATEST   | 2020-06-09T12:34:27.050+05:30 | com.amazonaws.serverless.exceptions.InvalidRequestEventException: Invalid Request: null   | 2020-06-09T12:34:27.050+05:30 | at io.micronaut.function.aws.proxy.MicronautRequestReader.readRequest(MicronautRequestReader.java:123)   | 2020-06-09T12:34:27.050+05:30 | at io.micronaut.function.aws.proxy.MicronautRequestReader.readRequest(MicronautRequestReader.java:48)   | 2020-06-09T12:34:27.050+05:30 | at io.micronaut.function.aws.proxy.AbstractLambdaContainerHandler.proxy(AbstractLambdaContainerHandler.java:204)   | 2020-06-09T12:34:27.050+05:30 | at io.micronaut.function.aws.runtime.MicronautLambdaRuntime.startRuntimeApiEventLoop(MicronautLambdaRuntime.java:131)   | 2020-06-09T12:34:27.050+05:30 | at io.micronaut.function.aws.runtime.MicronautLambdaRuntime.main(MicronautLambdaRuntime.java:77)   | 2020-06-09T12:34:27.050+05:30 | Caused by: java.lang.NullPointerException   | 2020-06-09T12:34:27.050+05:30 | at com.amazonaws.serverless.proxy.internal.jaxrs.AwsProxySecurityContext.getAuthenticationScheme(AwsProxySecurityContext.java:138)   | 2020-06-09T12:34:27.050+05:30 | at com.amazonaws.serverless.proxy.internal.jaxrs.AwsProxySecurityContext.getUserPrincipal(AwsProxySecurityContext.java:82)   | 2020-06-09T12:34:27.050+05:30 | at io.micronaut.function.aws.proxy.MicronautAwsProxyRequest.<init>(MicronautAwsProxyRequest.java:106)   | 2020-06-09T12:34:27.050+05:30 | at io.micronaut.function.aws.proxy.MicronautRequestReader.readRequest(MicronautRequestReader.java:70)   | 2020-06-09T12:34:27.050+05:30 | ... 4 more   | 2020-06-09T12:34:27.055+05:30 | END RequestId: d73e1527-0a04-4a3a-98f2-1f078c2e76b6 Do we need to do some changes to support AWS Gateway HTTP APIs?

msandy10 avatar Jun 09 '20 07:06 msandy10

Not sure it supported yet, guess the implementation needs updating to support incoming HTTP API requests

graemerocher avatar Jun 09 '20 07:06 graemerocher

Are we planning to support HTTP APIs request in near future, look like micronaut-function-aws-api-proxy library level change to support http request.

HTTP APIs are optimized for building APIs that proxy to AWS Lambda functions or HTTP backends, making them ideal for serverless workloads.

msandy10 avatar Jun 09 '20 07:06 msandy10

Not in the short term, but longer term makes sense, otherwise PRs are of course welcome!

graemerocher avatar Jun 09 '20 09:06 graemerocher

It looks like adding PayloadFormatVersion: "1.0" to the event section of a SAM yaml template is a way to dance around the issue.

kristofvb avatar Dec 12 '20 06:12 kristofvb

It looks like adding PayloadFormatVersion: "1.0" to the event section of a SAM yaml template is a way to dance around the issue.

Does this workaround still works for you? It does not for me (as it didn't matter at all).

inez avatar Sep 03 '22 23:09 inez