Sample serverless application using Micronaut, AWS Lambda and API Gateway
- Micronaut 2.5.11
- SAM
- MongoDB
- TestContainers
- Java 11
product-serverless-service % ./gradlew build
This command starts the docker containers, sam local api and build the project.
product-serverless-service % make run
1 - Configure intellij remote debugging.
2 - Execute this command
product-serverless-service % make debug
3 - Send request
4 - Start debug
1 - Create a lambda function in aws console using Java 11 Corretto runtime.
2 - Execute the gradle build and upload the jar located on build/libs path.
3 - Configure the function handler using MicronautLambdaHandler.
4 - Add an environment variable with the mongodb url. In this project I used mongodb atlas. Like amazon, they offer a database in free tier.
5 - Finally, you can send a api gateway event to the function and see the result.
1 - Create an api gateway of rest api type.
2 - Map methods and resources like product controller.
3 - For each method, select lambda function and enable lambda proxy integration.
4 - After that, you can test your functions.
5 - At last, after deploy your api gateway, it will be avaliable to access.