Mahabali / AWSLambdaWithSpringBoot

AWSLambdaWithSpringBoot - No Spring JPA

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AWSLambdaWithSpringBoot

AWSLambdaWithSpringBoot - No Spring JPA

Purpose

  1. Quick Starter Project for those who like to see how Maven + Spring Boot + AWS Lambda + API Gateway works
  2. As a whole, its a way to try Serverless Architecture using Java

Pre-requisites

  1. Java 8 and Maven
  2. AWS Account

Steps

  1. Clone the Repo
  2. Use IDE like VSCode or Eclipse. If VSCode, open the workspace file
  3. Study the code🤷‍♂️
  4. Make a maven build using mvn package from command line/terminal. JAR file will be created
  5. Open AWS Lambda. Create a function and once created provide the handler name as com.serverless.rest.restapi.handler.AWSHandler::handleRequest as shown below. Upload JAR file here. LambdaHandler
  6. Do not configure API Gateway from AWS Lambda. Instead Go to API Gateway in AWS. Create a new API.
  7. You have to create 2 resource and 1 child resource. /post , /posts and {id} as sub child for posts . Note the difference between post and posts Create Resource Configure Path parameter
  8. Now create methods for these resources POST for /post, GET for posts, PUT and DELETE for {id} child resource. Configure as shown below. Enter the lambda which you created in function name to link. enter image description here
  9. Finally it should look something like this Final look
  10. Deploy API like this. Select any stage name. Deploy
  11. Get the API gateway URL and test using Postman or curl

Note

  1. This is more like a quick POC. So its not the best way to write code.
  2. Add tests in real world.

If it helped you

🍻 Write me a quick and simple recommendation for me in linkedin

About

AWSLambdaWithSpringBoot - No Spring JPA

License:MIT License


Languages

Language:Java 100.0%