3
votes

The documentation shows that the exposed handler (via io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler::handleRequest in the packaged application) is configured by setting quarkus.lambda.handler in application.properties. However in my case I'd like to deploy multiple handlers from the same project.

Does anyone know of a way, or whether it's possible, to expose more than a single handler from a quarkus-lambda project?

Edit: After reading through https://github.com/quarkusio/quarkus/blob/master/extensions/amazon-lambda/runtime/src/main/java/io/quarkus/amazon/lambda/runtime/AmazonLambdaRecorder.java#L89 it seems that this is indeed not possible right now, is that correct?

1
The Quarkus lambda handler is just an entrypoint for the AWS lambda runtime to enter your application. Past that point, what you do is completely up to you. So you don't really need multiple Quarkus lambda handlers. All you need is one handler for you to be able to receive Lambda events. You can then use the contextual information from the Lambda to route the processing elsewhere inside your application, combined with a pattern like Command or Strategy. Is there a hard reason you must have multiple lambda handlers? - kolossus
I realize I can do that, however our current strategy has been to leverage API gateway integration towards out lambdas using the NodeJS runtime. So say I have a GET on /pets/{id}, and a POST on /pets in the API gateway, then these would integrate both with different handlers in the same deployment. The upside is that we can use LPP on the lambdas, we can use different IAM policies per endpoint, etc, while still using a shared codebase per service. I think using the "monolambda" approach you're describing means we'd have to give up at least some of that. - bcd
Right re:giving up granular access control. Otherwise, you'll need to slim down your Quarkus app to be a true micro service. - kolossus

1 Answers

0
votes

You should just write a RestEasy Resource and then follow the steps written here:

https://quarkus.io/guides/amazon-lambda-http

For a full example with RestEasy & DynamoDB, read these:

Basically, the idea is that you just write Rest Resources in Quarkus and Quarkus deploys & configures all your Resource endpoints as Api-Gateways and Lambda's & Handlers in AWS via the SAM CLI.

Make sure you have these 2 dependencies in your classpath:

    <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>url-connection-client</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-amazon-lambda-http</artifactId>
    </dependency>

Then run:

mvn clean install

To make sure that the necessary artifacts are created in your /target folder.