Get Started

It’s a snap to be up and running with Microlam.

Step 1

Create the Getting Started Application

Prerequisites: JDK 11+, maven, docker, AWS CLI, AWS CDK CLI

Run this script in your CLI:


mvn archetype:generate -DarchetypeGroupId=io.microlam -DarchetypeArtifactId=microlam-lambda-quickstart -DarchetypeVersion=0.9.1
                 

And answer all the questions:

  • Choose a groupId, artifactId, version and package for your project.
  • 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 profile
  • Choose your awsRegion: this is the name of an AWS region (ex: eu-west-1)
  • Choose your lambdaName: this is the name of your Lambda (must be also suitable as the name of the Java class for the Lambda).
  • Step 2

    (Optional) Generate the Lambda native compilation configuration

    This project is already configured and ready for building, so you may skip to Step 4 directly...

    Run this script in your CLI:

    
    mvn clean install -Dnative=java11-amd64 -Pconfig
                     

    At the end of the build, you will find the Java deployment package in the target/ folder with the name [artifactId]-[version]-aws-lambda.jar.
    Also a docker container is running, letting you try your Java lambda locally with the GraalVM Tracing Agent.

    The generated configuration is updated every 30s in folder: src/main/resources/META-INF/native-image/[groupId]/[artifactId]/.

    With your IDE, you can run the the Junit Tests in class in [package].devops.LocalLambdaTests or use maven for that:

    
    mvn test -Dtest=[package].devops.LocalLambdaTests
            

    Everything is ok ? It is time to build and test the Lambda Native deployment package.

    Step 3

    (Optional) Build your project in dev mode

    Run this script in your CLI:

    
    mvn clean install -Dnative=java11-amd64 -Pcompile,dev
                     

    Take some tea of coffee while the build is running because it may take some time for the first time...

    At the end of the build, a docker container is running, letting you try your native lambda locally, before deploying to AWS.

    With your IDE, you can run the the Junit Tests in class in [package].devops.LocalLambdaTests or use maven for that:

    
    mvn test -Dtest=[package].devops.LocalLambdaTests
          

    Everything is ok ? It is time to extract the Lambda Native deployment package.

    Run this script in another CLI:

    
    mvn docker:copy -Dnative=java11-amd64 -Pcompile
          

    This will copy the Native deployment package to the target/ folder with the name [artifactId]-[version]-aws-lambda-native.zip.

    You can stop the running container with CTRL-C.

    Step 4

    Build your project

    Run this script in your CLI:

    
    mvn clean install -Dnative=java11-amd64 -Pcompile
                     

    Take some tea of coffee while the build is running because it may take some time for the first time...

    At the end of the build, you will find the Native deployment package in the target/ folder with the name [artifactId]-[version]-aws-lambda-native.zip.

    Step 5

    Deploy the Getting Started Application to AWS with the CDK

    You need to apply a few changes to the class [package].devops.cdk.CreateApp (from src/test folder), to set the function Runtime, Architecture and Code.

    Run this script in your CLI:

    
    cdk deploy
                     

    Boom! Your Microlam app is now deployed to AWS

    Next Steps

    Getting started - The Reference Guide

    Getting started - The Reference Guide.

    Want to learn more? Check out the guides to continue your journey.