Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute AWS lambda with Open JDK 11+ as custom runtime?

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?

like image 381
veben Avatar asked Feb 15 '19 10:02

veben


People also ask

Does AWS Lambda support Java 11?

You can use your existing tools such as Eclipse or IntelliJ IDEA to author Java code and use Maven for packaging your Java code, making it easy to integrate AWS Lambda into your existing development processes. To get started, just upload your code through the AWS Lambda console or CLI and select the Java 11 runtime.

How do I change the runtime version of Lambda?

To change the runtime, you create a new container image. When you use a . zip file archive for the deployment package, you choose a runtime when you create the function. To change the runtime, you can update your function's configuration.

What is custom runtime in AWS Lambda?

You can implement an AWS Lambda runtime in any programming language. A runtime is a program that runs a Lambda function's handler method when the function is invoked. You can include a runtime in your function's deployment package in the form of an executable file named bootstrap .


1 Answers

There's no longer a need to use a custom runtime, as AWS Lambda now supports Java 11.

However, Lambda functions that use this runtime will be run with Amazon Corretto 11 and not OpenJDK 11.

If you wish to run your Lambda function with OpenJDK 11 instead of Corretto 11, then using a custom runtime is still recommended.

like image 101
Jacob G. Avatar answered Sep 27 '22 20:09

Jacob G.