-1

I have a java spring boot application that runs a job to upload data to Database after polling a message from SQS and this application also contains a REST API over that same database.

Now I need to decouple the upload functionality and REST API.

Upload functionality would be done by an AWS Batch Job which would be triggered by a lambda. Rest API would be simply as it was before.

Challenge is that I need to do all these operations within the same code repo. This is to avoid having 3 repositories one for REST API, another for the AWS Batch Job, and the last for AWS lambda handler.

Thus trying to find out solutions that spring boot can provide to run a same application in different modes. Please help.

Tarun Kundhiya
  • 156
  • 1
  • 9

1 Answers1

-1

I won't recommend using Spring Boot for lambda - technically you can, but it's waste of money. Spring Boot is overhead for java, it requires more memory, so it's more expensive.

You need to create a multi-module Maven application. The modules would be:

  1. Existing Spring Boot app.
  2. Batch job.
  3. Common code, used by modules 1 & 2.
  4. Simple new lambda.
  5. ... more modules if you need ...

But if you still sure that for some reason you want to wrap existing Spring Boot app into lambda, this library would help you:

https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Spring-Boot

stepio
  • 865
  • 2
  • 9
  • 22
  • thanks for sharing this information about cost. Can you please share is there is something for grade and my question was more for how to run each of them separately like on CLI I can provide whether this module would run or other. Please share answer for that. – Tarun Kundhiya Jun 15 '20 at 09:32
  • I explained 2 possible approaches, now it's your job to investigate them deeper. – stepio Jun 15 '20 at 14:53