Building AWS Lambda jar

What is the standard practice for creating AWS Lambda jar.

Should we bundle the dependencies as jars within the zip file or should the dependencies be unjarred and included as classes.

As far as I know it is the first option that holds true, but this doubt came to mind when I was following the AWS Tutorial of thumbnails and it eventually created a jar that had classes for dependencies (like Jackson) rather than bundling Jackson jar in the artifact.

Is there a sample AWS Lambda zip file that I can download and try (the one that has dependencies bundled as .jar files and not as .class files)

Answers 1

  • You should include the dependency jars in a lib subdirectory. If you have a class mypackage.LambdaFunctionHandler, the zip file should have this basic structure:

    |-- mypackage
    |   +-- LambdaFunctionHandler.class
    +-- lib
        |-- myjar1.jar
        +-- myjar2.jar

Related Articles