Deploy your Java Lambda easily with Microlam!

Why a new Java Framework ?

While excellent frameworks, like Micronaut and Quarkus, are already available for that, I found that it is often difficult to enter into their worlds, because their scope is so big that a beginner may be overwhelmed with the amount of knowledge you need to start with them.

In case you are new to AWS Cloud, it is time to begin!

AWS (Amazon Web Services) is the leader of all cloud providers. A revolution in the cloud was to offer Serverless Services which means that they are managed services and you pay only what you consume, giving this wonderful opportunity to begin your dreamed project without any upfront costs and very easily. The main Serverless Service is AWS Lambda giving you the possibility to run a given piece of code when a given event is occurring, for example, you may have a Web site or an App using a REST API, created with ease with AWS API Gateway, which redirect the work to AWS Lambda. In case you don’t have already an account, you may create it in 2 minutes and get a one year free offer including 1.000.000 lambda requests / month !!!!

What you need to start ?

  • Create an AWS Account, install the AWS CLI and configure an aws named profile, then install also the AWS CDK CLI.
  • Install Docker (just in case you want to compile natively)
  • Be a Java developer with an IDE, a JDK 11+ installed, maven installed, but this you should use them already. Note that AWS is providing a free supported OpenJDK build named Corretto for Java 11 or Java 17… that is used inside the AWS Java Lambda Runtime, so it is a good idea to choose it.

Let’s begin!

For a complete presentation, see the complete getting started guide.

mvn archetype:generate -DarchetypeGroupId=io.microlam -DarchetypeArtifactId=microlam-lambda-quickstart -DarchetypeVersion=0.8.4
  • Choose your awsBucket : this is the name of the S3 bucket where the lambda artifacts will be deployed
  • Choose your awsProfile : this is the name of your AWS named profile
  • Choose your awsRegion: this is the name of an AWS region (ex: eu-west-1), choose one next to your users.
  • Choose your lambdaName: this is the name of your Lambda (must be also suitable as the name of the Java class for the Lambda).
AWS Architecture of the getting started project

Let’s compile the Java code and generate a Java Lambda Package:

mvn package -Pjava

Deployment with AWS CDK

The CDK allow you to deploy your architecture and your code using Java code. The getting started example includes already a test class, named CreateApp you can use to deploy to AWS:

cdk deploy --profile <your named profile>
cdk bootstrap --profile <your named profile>

Let’s test the new API with curl

curl -d "{\"arguments\":[2, 4, 6]}" -H "Content-Type: application/json" https://xxxxxxxxx.execute-api.<region>

How to clean your AWS Account

After playing with the API and checking the result in AWS console (check API Gateway, Lambda, S3 in your region), you may want to clean your AWS account.

cdk destroy --profile <your named profile>

Remarks on using a Java Lambda

The only problems we could find on using a Java Lambda are the problem of the cold start and the requirement on memory.


Even if you begin with Cloud development, I hope you will find a precious help using Microlam micro-framework.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Frank Afriat

Frank Afriat

Founder and CTO of Solusoft.Tech, Java Expert & Architect, AWS Serverless happy user and flutter early adopter.