I'm trying to create an AWS Lambda function with micronaut using functions i.e. I created my poc project with:
mn create-function-app --build=maven --jdk=11 micronaut-test
I can build and deploy it to AWS very easily but I wonder if there is a way to run it locally so I can quickly test changes in the same way you can run a regular micronaut app with
mvn mn:run
Right now is just the sample app, reformulating my question; Can I trigger the execute method in BookRequestHandler without uploading it to AWS?
Thanks in advance.
Maven profiles can be used to select the runtime (in this expample uses netty) and the main class:
Create the main class with a controller with a Post method that calls the function
and run with
Now you can use
returning
This a bit hacky, to test your function you can see micronaut-test/src/test/java/micronaut/test/BookRequestHandlerTest.java class or see Testing Lambda Handlers official docs.
Note: For applications created with mn create-app -f aws-lambda ... is not needed the <exec.mainClass> in pom.xml, and the Application.java is generated.