Quarkus
Introduction
Section titled “Introduction”Quarkus is a Java framework optimized for cloud, serverless, and containerized environments. Quarkus leverages a Kubernetes Native Java stack tailored for GraalVM & OpenJDK HotSpot, which further builds on various Java libraries and standards.
Localstack is supported by Quarkus as a Dev service for Amazon Services. Quarkus Amazon Services automatically starts a LocalStack container in development mode and when running tests, and the extension client is configured automatically.
Getting started
Section titled “Getting started”In this guide, we will demonstrate how you can create a service client for creating and managing Lambdas on LocalStack. The Lambda extension is based on AWS Java SDK 2.x.
Prerequisites
Section titled “Prerequisites”- LocalStack installed and running
- JDK 17+ with
JAVA_HOMEconfigured properly - Maven 3.8.1+
- Docker
Create a Maven project
Section titled “Create a Maven project”Create a new project with the following command:
mvn io.quarkus.platform:quarkus-maven-plugin:3.6.3:create \ -DprojectGroupId=org.acme \ -DprojectArtifactId=amazon-lambda-quickstart \ -DclassName="org.acme.lambda.QuarkusLambdaSyncResource" \ -Dpath="/sync" \ -Dextensions="resteasy-reactive-jackson,amazon-lambda"cd amazon-lambda-quickstartThe above command generates a Maven project structure with imports for RESTEasy Reactive/JAX-RS and Amazon Lambda Client extensions.
Configure Lambda Client
Section titled “Configure Lambda Client”Both Lambda clients (sync and async) can be configured through the application.properties file, which should be located in the src/main/resources directory.
Additionally, ensure that a suitable implementation of the sync client is added to the classpath.
By default, the extension employs the URL connection HTTP client, so it’s necessary to include a URL connection client dependency in the pom.xml file:
<dependency> <groupId>software.amazon.awssdk</groupId> <artifactId>url-connection-client</artifactId></dependency>If you want to use Apache HTTP client instead, configure it as follows in application.properties:
quarkus.lambda.sync-client.type=apacheAdd the following dependencies to the pom.xml file:
<dependency> <groupId>software.amazon.awssdk</groupId> <artifactId>apache-client</artifactId></dependency>To configure LocalStack, add the following properties to the application.properties file:
quarkus.lambda.endpoint-override=http://localhost:4566
quarkus.lambda.aws.region=us-east-1quarkus.lambda.aws.credentials.type=staticquarkus.lambda.aws.credentials.static-provider.access-key-id=test-keyquarkus.lambda.aws.credentials.static-provider.secret-access-key=test-secretPackage the application
Section titled “Package the application”You can package the application with the following command:
./mvnw clean packageYou can further run the application in dev mode with the following command:
java -Dparameters.path=/quarkus/is/awesome/ -jar target/quarkus-app/quarkus-run.jarSupported extensions
Section titled “Supported extensions”Configuration
Section titled “Configuration”The following configuration properties are fixed at build time. All the other configuration properties can be overridden at runtime.
| Property | Type | Default |
|---|---|---|
quarkus.aws.devservices.localstack.image-name | string | localstack/localstack:3.0.1 |
quarkus.aws.devservices.localstack.init-scripts-folder | string | |
quarkus.aws.devservices.localstack.init-scripts-classpath | string | |
quarkus.aws.devservices.localstack.init-completion-msg | string | |
quarkus.aws.devservices.localstack.container-properties | Map<String,String> | |
quarkus.aws.devservices.localstack.additional-services."additional-services".enabled | boolean | |
quarkus.aws.devservices.localstack.additional-services."additional-services".shared | boolean | false |
quarkus.aws.devservices.localstack.additional-services."additional-services".service-name | string | localstack |
quarkus.aws.devservices.localstack.additional-services."additional-services".container-properties | Map<String,String> |
Specific configuration
Section titled “Specific configuration”Dev Services can support specific configurations passed to the LocalStack container. These configurations can be globally applied to all containers or specified individually per service.
quarkus.aws.devservices.localstack.image-name=localstack/localstack:3.0.3quarkus.dynamodb.devservices.container-properties.DYNAMODB_HEAP_SIZE=1GAdditional services
Section titled “Additional services”To start additional services for which a Quarkus extension does not exist or is not imported in the project, use the additional-services property:
quarkus.aws.devservices.localstack.additional-services."kinesis".enabled=truequarkus.aws.devservices.localstack.additional-services."redshift".enabled=true