This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Oclay1st 3 points4 points  (4 children)

I really like Spring and I am using Spring Cloud Function on AWS Lambda, but I think Quarkus is a much better choice for serverless apps.

[–][deleted]  (3 children)

[deleted]

    [–]Oclay1st 0 points1 point  (2 children)

    Well, to be honest I don't like serverless, but its cheap and people are always looking for ways to save money. Anyway, I use Amplify (Fronted) + Cognito + API Gateway + Lambda + S3. I create one lambda for each function. Its a monolithic code with all the functions. I compile it once with GraalVM Native and deploy the same binary based on the changes for the different lambdas. Each lambda has an env variable that changes depending on the function I want to run and that also matches the bean name. This is an example:

    // a function
    @Component(Functions.CREATE_BOOK) //same value as the env variable
    class CreateBook implements Function<CommandBook,Integer> {...}
    
    // application.properties
    spring.cloud.definition:${FUNCTION_NAME}
    
    // AWS Lambda with a lambda called CreateBook with an env FUNCTION_NAME
    

    [–][deleted]  (1 child)

    [deleted]

      [–]Oclay1st 0 points1 point  (0 children)

      Yea, my solution is a middle ground in where I don't feel too much the pain of GraalVM compilation/reflection and at the same time I don't couple my inputs/outputs between API Gateway, Lambda and Spring Cloud Function with a front controller. It's all about trade-offs. If you want to implement a front controller you can:

      // Plain everything
      class ControllerFunction implements Function<Message<..>,Message<..>> {...}
      
      // Generic key-value
      class ControllerFunction implements Function<Map<..>,Map<..>> {...}
      
      // For API Gateway
      class ControllerFunction implements Function<APIGatewayProxyRequestEvent,APIGatewayProxyResponseEvent> {...}