Amazon AppConfig Client

Amazon AppConfig is a service for managing application configurations.

You can find more information about AppConfig at the Amazon AppConfig website.

The AppConfig extension is based on AWS Java SDK 2.x. It’s a major rewrite of the 1.x code base that offers two programming models (Blocking & Async).

The Quarkus extension supports two programming models:

  • Blocking access using URL Connection HTTP client (by default) or the Apache HTTP Client

  • Asynchronous programming based on JDK’s CompletableFuture objects and the Netty HTTP client (by default) or the AWS CRT-based HTTP client

You can use this extension to integrate AppConfig capabilities in your Quarkus applications using the AWS SDK for Java 2.x.

The AppConfig extension is based on AWS Java SDK 2.x. It’s a major rewrite of the 1.x code base that offers two programming models (Blocking & Async).

The Quarkus extension supports two programming models:

  • Blocking access using URL Connection HTTP client (by default), the Apache HTTP Client or the AWS CRT-based HTTP client

  • Asynchronous programming based on JDK’s CompletableFuture objects and the Netty HTTP client or the AWS CRT-based HTTP client

Configuring AppConfig clients

Both AppConfig clients (sync and async) are configurable via the application.properties file that can be provided in the src/main/resources directory. Additionally, you need to add to the classpath a proper implementation of the sync client. By default, the extension uses the URL connection HTTP client, so you need to add a URL connection client dependency to the pom.xml file:

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>url-connection-client</artifactId>
</dependency>

If you want to use the Apache HTTP client instead, configure it as follows:

quarkus.appconfig.sync-client.type=apache

And add the following dependency to the application pom.xml:

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>apache-client</artifactId>
</dependency>

If you want to use the AWS CRT-based HTTP client instead, configure it as follows:

quarkus.appconfig.sync-client.type=aws-crt

And add the following dependency to the application pom.xml:

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>aws-crt-client</artifactId>
</dependency>

To enable the asynchronous client, we also need to add the Netty HTTP client dependency to the pom.xml:

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>netty-nio-client</artifactId>
</dependency>

If you want to use the AWS CRT-based HTTP client instead, configure it as follows:

quarkus.appconfig.async-client.type=aws-crt

And add the following dependency to the application pom.xml:

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>aws-crt-client</artifactId>
</dependency>

If you’re going to use a local AppConfig instance (for example a LocalStack), configure it as follows:

quarkus.appconfig.endpoint-override=http://localhost:4566 (1)

quarkus.appconfig.aws.region=us-east-1 (2)
quarkus.appconfig.aws.credentials.type=static (3)
quarkus.appconfig.aws.credentials.static-provider.access-key-id=test-key
quarkus.appconfig.aws.credentials.static-provider.secret-access-key=test-secret
1 Override the AppConfig client to use LocalStack instead of the actual AWS service
2 Localstack defaults to us-east-1
3 The static credentials provider lets you set the access-key-id and secret-access-key directly

If you want to work with an AWS account, you can simply remove or comment out all Amazon AppConfig related properties. By default, the AppConfig client extension will use the default credentials provider chain that looks for credentials in this order:

  • Java System Properties - aws.accessKeyId and aws.secretAccessKey

  • Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY

  • Credential profiles file at the default location (~/.aws/credentials) shared by all AWS SDKs and the AWS CLI

  • Credentials delivered through the Amazon ECS if the AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variable is set and the security manager has permission to access the variable,

  • Instance profile credentials delivered through the Amazon EC2 metadata service

And the region from your AWS CLI profile will be used.

Usage

You can inject the AppConfig client in your Quarkus beans using:

import software.amazon.awssdk.services.appconfig.AppConfigClient;
import software.amazon.awssdk.services.appconfig.model.ListApplicationsRequest;
import software.amazon.awssdk.services.appconfig.model.ListApplicationsResponse;

import jakarta.inject.Inject;
import jakarta.enterprise.context.ApplicationScoped;

@ApplicationScoped
public class AppConfigService {

    @Inject
    AppConfigClient appConfigClient;

    public void listApplications() {
        ListApplicationsResponse response = appConfigClient.listApplications(ListApplicationsRequest.builder().build());
        // Handle response, e.g. iterate over response.items()
    }
}

Configuration Reference

The AppConfig extension is based on AWS Java SDK 2.x. It’s a major rewrite of the 1.x code base that offers two programming models (Blocking & Async).

The Quarkus extension supports two programming models:

  • Blocking access using URL Connection HTTP client (by default), the Apache HTTP Client or the AWS CRT-based HTTP client

  • Asynchronous programming based on JDK’s CompletableFuture objects and the Netty HTTP client or the AWS CRT-based HTTP client

Configuring AppConfig clients

Both AppConfig clients (sync and async) are configurable via the application.properties file that can be provided in the src/main/resources directory. Additionally, you need to add to the classpath a proper implementation of the sync client. By default, the extension uses the URL connection HTTP client, so you need to add a URL connection client dependency to the pom.xml file:

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>url-connection-client</artifactId>
</dependency>

If you want to use the Apache HTTP client instead, configure it as follows:

quarkus.appconfig.sync-client.type=apache

And add the following dependency to the application pom.xml:

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>apache-client</artifactId>
</dependency>

If you want to use the AWS CRT-based HTTP client instead, configure it as follows:

quarkus.appconfig.sync-client.type=aws-crt

And add the following dependency to the application pom.xml:

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>aws-crt-client</artifactId>
</dependency>

To enable the asynchronous client, we also need to add the Netty HTTP client dependency to the pom.xml:

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>netty-nio-client</artifactId>
</dependency>

If you want to use the AWS CRT-based HTTP client instead, configure it as follows:

quarkus.appconfig.async-client.type=aws-crt

And add the following dependency to the application pom.xml:

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>aws-crt-client</artifactId>
</dependency>

If you’re going to use a local AppConfig instance (for example a LocalStack), configure it as follows:

quarkus.appconfig.endpoint-override=http://localhost:4566 (1)

quarkus.appconfig.aws.region=us-east-1 (2)
quarkus.appconfig.aws.credentials.type=static (3)
quarkus.appconfig.aws.credentials.static-provider.access-key-id=test-key
quarkus.appconfig.aws.credentials.static-provider.secret-access-key=test-secret
1 Override the AppConfig client to use LocalStack instead of the actual AWS service
2 Localstack defaults to us-east-1
3 The static credentials provider lets you set the access-key-id and secret-access-key directly

If you want to work with an AWS account, you can simply remove or comment out all Amazon AppConfig related properties. By default, the AppConfig client extension will use the default credentials provider chain that looks for credentials in this order:

  • Java System Properties - aws.accessKeyId and aws.secretAccessKey

  • Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY

  • Credential profiles file at the default location (~/.aws/credentials) shared by all AWS SDKs and the AWS CLI

  • Credentials delivered through the Amazon ECS if the AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variable is set and the security manager has permission to access the variable,

  • Instance profile credentials delivered through the Amazon EC2 metadata service

And the region from your AWS CLI profile will be used.

For more information, check out: - AWS AppConfig Documentation