quarkus: HTTP Lambda doesn't work with AWS Custom Domains

Describe the bug I have an issue when I’m using my REST API with Custom Domain. Note : When I use the InvokeURL it’s all good though. I’m using the maven archetype from the quarkus guide.

The issue is that with a Custom Domain (base path = hello) the root endpoint /hello doesn’t work (missing token error). I can call /hello/myName for instance (I created a new endpoint that prints Hello + id). Looks like I have to add a mapping in my resource : ANY on / but I can’t understand why… It works just fine using the InvokeURL …

Expected behavior My API should work seamlessly with or without Custom Domain.

Actual behavior The API works fine using the InvokeURL, but the root endpoint is not accessible using Custom Domain.

To Reproduce

  • Generate the maven archetype from this quarkus guide.
  • Deploy the stack using the guide again
  • Create a Custom Domain and link the hello base path this this API
  • Call your API with the custom domain, it doesn’t work (missing token error)

Environment (please complete the following information):

  • Output of uname -a or ver: Darwin MacBook-Pro-de-Jonathan.local 19.6.0 Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64 x86_64
  • Output of java -version: java version “11.0.8” 2020-07-14 LTS Java™ SE Runtime Environment 18.9 (build 11.0.8+10-LTS) Java HotSpot™ 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode)
  • GraalVM version (if different from Java):
  • Quarkus version or git rev: 1.10.2.FINAL
  • Build tool (ie. output of mvnw --version or gradlew --version): Apache Maven 3.6.3

Thanks

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 22 (14 by maintainers)

Most upvoted comments

Ah, that’s where the misunderstanding has been in a few tickets, now I see. 😃

There are indeed two JSON models, with REST API’s you can choose which one you use. With HTTP API’s (different service grouped under API Gateway, with different features, cheaper, faster startup, native OIDC, …) and this can only handle the v2.0 payload. https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html

One of the features that is not implemented in HTTP API service is the Binary Media Type, which I guess Quarkus depends on?

You can test this out by changing the AWS SAM template where it says type Type: Api to Type: HttpApi, you’ll also need remove/change the Outputs section because the variable used there is not known for HttpApis. When you invoke then you’ll see a NullPointer in the quarkus part:

2021-01-31 16:51:37,110 ERROR [qua.ama.lam.http] (main) Request Failure: java.lang.NullPointerException
at io.netty.handler.codec.http.HttpMethod$EnumNameMap.hashCode(HttpMethod.java:211)

BTW, with the current release 1.11.0.FInal, you should be able to use HttpApi if you switch to using the 1.0 protocol

 Type: AWS::Serverless::Function
  Properties:
    Handler: io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler::handleRequest
    Runtime: java11
    CodeUri: function.zip
    MemorySize: 512
    Policies: AWSLambdaBasicExecutionRole
    Timeout: 15
    Events:
      HttpApiEvent:
        Type: HttpApi
        PayloadFormatVersion: 1.0