Maven Archetype for lambda function using AWS SDK for Java 2.x

December 29, 2025 ยท View on GitHub

Description

This is an Apache Maven Archetype to create a lambda function template using AWS Java SDK 2.x. The generated template has the optimized configurations and follows the best practices to reduce start up time. Please check out AWS Dev Guide for more information.

Usage

You can use mvn archetype:generate to generate a project using this archetype. See maven archetype usage guidance for more information. Note that you need to replace ${version} with the latest SDK version found in README.md.

  • Interactive mode
mvn archetype:generate \
  -DarchetypeGroupId=software.amazon.awssdk \
  -DarchetypeArtifactId=archetype-lambda \
  -DarchetypeVersion=${version}
  • Batch mode
mvn archetype:generate \
    -DarchetypeGroupId=software.amazon.awssdk \
    -DarchetypeArtifactId=archetype-lambda \
    -DarchetypeVersion=${version} \
    -DgroupId=com.test \
    -DartifactId=sample-project \
    -Dservice=s3  \
    -DinteractiveMode=false

Parameters

Parameter NameDefault ValueDescription
service (required)n/aSpecifies the service client to be used in the lambda function, eg: s3, dynamodb. You can find available services here.
groupId(required)n/aSpecifies the group ID of the project
artifactId(required)n/aSpecifies the artifact ID of the project
regionn/aSpecifies the region to be set for the SDK client in the application
httpClientaws-crt-clientSpecifies the http client to be used by the SDK client. Available options are url-connection-client (sync), apache-client (sync), netty-nio-client (async) and aws-crt-client(async). See http clients
handlerClassName"App"Specifies the class name of the handler, which will be used as the lambda function name. It should be camel case.
javaSdkVersionSame version as the archetype versionSpecifies the version of the AWS Java SDK 2.x to be used
version1.0-SNAPSHOTSpecifies the version of the project
package${groupId}Specifies the package name for the classes

Deployment

To deploy the lambda function, you can use SAM CLI. The generated project contains a default SAM template file template.yaml where you can configure different properties of your lambda function such as memory size and timeout.

sam deploy --guided

Please refer to deploying lambda apps for more info.