Amazon AppConfigData Client
Amazon AppConfigData is a service for managing application configurations.
You can find more information about AppConfigData at the Amazon AppConfigData website.
| The AppConfigData 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
CompletableFutureobjects and the Netty HTTP client (by default) or the AWS CRT-based HTTP client
You can use this extension to integrate AppConfigData capabilities in your Quarkus applications using the AWS SDK for Java 2.x.
| The AppConfigData 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
CompletableFutureobjects and the Netty HTTP client or the AWS CRT-based HTTP client
Configuring AppConfigData clients
Both AppConfigData 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.appconfigdata.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.appconfigdata.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.appconfigdata.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 AppConfigData instance (for example a LocalStack), configure it as follows:
quarkus.appconfigdata.endpoint-override=http://localhost:4566 (1)
quarkus.appconfigdata.aws.region=us-east-1 (2)
quarkus.appconfigdata.aws.credentials.type=static (3)
quarkus.appconfigdata.aws.credentials.static-provider.access-key-id=test-key
quarkus.appconfigdata.aws.credentials.static-provider.secret-access-key=test-secret
| 1 | Override the AppConfigData 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 AppConfigData related properties. By default, the AppConfigData client extension will use the default credentials provider chain that looks for credentials in this order:
-
Java System Properties -
aws.accessKeyIdandaws.secretAccessKey -
Environment Variables -
AWS_ACCESS_KEY_IDandAWS_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_URIenvironment 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 AppConfigData client in your Quarkus beans using:
import software.amazon.awssdk.services.appconfigdata.AppConfigDataClient;
import software.amazon.awssdk.services.appconfigdata.model.GetLatestConfigurationRequest;
import software.amazon.awssdk.services.appconfigdata.model.GetLatestConfigurationResponse;
import jakarta.inject.Inject;
import jakarta.enterprise.context.ApplicationScoped;
@ApplicationScoped
public class AppConfigDataService {
@Inject
AppConfigDataClient appConfigDataClient;
public void listApplications() {
GetLatestConfigurationResponse response = client.getLatestConfiguration(GetLatestConfigurationRequest.builder().build());
// Handle response, e.g. iterate over response.items()
}
}
Configuration Reference
| The AppConfigData 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
CompletableFutureobjects and the Netty HTTP client or the AWS CRT-based HTTP client
Configuring AppConfigData clients
Both AppConfigData 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.appconfigdata.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.appconfigdata.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.appconfigdata.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 AppConfigData instance (for example a LocalStack), configure it as follows:
quarkus.appconfigdata.endpoint-override=http://localhost:4566 (1)
quarkus.appconfigdata.aws.region=us-east-1 (2)
quarkus.appconfigdata.aws.credentials.type=static (3)
quarkus.appconfigdata.aws.credentials.static-provider.access-key-id=test-key
quarkus.appconfigdata.aws.credentials.static-provider.secret-access-key=test-secret
| 1 | Override the AppConfigData 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 AppConfigData related properties. By default, the AppConfigData client extension will use the default credentials provider chain that looks for credentials in this order:
-
Java System Properties -
aws.accessKeyIdandaws.secretAccessKey -
Environment Variables -
AWS_ACCESS_KEY_IDandAWS_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_URIenvironment 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.
Related Guides
For more information, check out: - AWS AppConfigData Documentation