AWS allows to create Lambda function with Java 8
(OpenJDK 8) as runtime.
I need to create a simple function using Open JDK 11
. Something like that:
package example;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
public class Hello {
public String myHandler(int myCount, Context context) {
LambdaLogger logger = context.getLogger();
logger.log("received : " + myCount);
return String.valueOf(myCount);
}
}
There is an option allowing to use a custom runtime and a tutorial that contains an example with Shell. However there is no example with Java
.
Is anyone have already deal with an AWS lambda with custom java runtime?
I was also curious as to why we haven't seen any custom runtimes for Java yet, so about a month ago I started playing around with the idea of building one in Java 11 using Jigsaw to produce small runtime. While it's not exactly a tutorial, I did write a fairly detailed Readme on how to build this and the code is simple enough to follow.
Here's my project on GitHub:
https://github.com/andthearchitect/aws-lambda-java-runtime
I just published this recently and it's most certainly a POC so use at your own risk.
Corretto seems interesting but I would guess there will still be people out there who are more comfortable with the official OpenJDK release. I'm hoping maybe this can be the starting point for a production ready open source runtime for Java.