By using AWS re:Post, you agree to the Terms of Use

AppConfig usage with AWS Java SDK v2



The Java SDK for AppConfig changed between versions v1 and v2. Dependencies below:

  • v1: com.amazonaws:aws-java-sdk-appconfig:1.12.257
  • v2: (needs platform(" .awssdk:bom:2.17.228")

The question is: how to fetch an AppConfig configuration profile value from Java using the v2 API? Is there a code example available?

I was able to find a code example about how to use the v1 API:

However, I am unable to find a code example for the same purpose for the v2 API.

I have some partial progress:

  • This will provide the AWS AppConfig client:
    public AppConfigClient buildV2() {
        return AppConfigClient.create();
  • This will call AppConfig to get a configuration profile response:
    private GetConfigurationProfileResponse fetchConfigurationResult(ConfigurationProfiles.Key configurationProfileKey) {
        GetConfigurationProfileRequest request = GetConfigurationProfileRequest.builder()
            // environment?

        GetConfigurationProfileResponse response = appConfigClient.getConfigurationProfile(request);

        return response;

What I don't know are:

  • How to pass the AppConfig environment to the GetConfigurationProfileRequest instance
  • I understand I have to get an AppConfig token between the calls tp create and fetchConfigurationResult. How to use the v2 API to get that token?
  • After getting the GetConfigurationProfileResponse instance, how to use it for getting the actual configuration profile value? The v1 API has some methods in the GetConfigurationResult class like getContentType and getContent


1 Answer


One should be looking at the appconfigdata package rather than the appconfig package. This contains the two data plane APIs (StartConfigurationSession and GetLatestConfiguration) that can be used to fetch deployed configuration.

More information here using CLI (which can be converted into your desired SDK code) -

Here's an example in Java on how you can go about integrating with our data plane.

  • Example of how to start a session -
String sessionToken = client.startConfigurationSession(
                        .applicationIdentifier("some application name")
                        .environmentIdentifier("some environment name")
                        .configurationProfileIdentifier("some config profile name")
  • and call to get latest configuration using that initial token -
while(true) {
GetLatestConfigurationResponse getLatestConfigurationResponse = client.getLatestConfiguration(

if(getLatestConfigurationResponse.content().asByteArray().size > 0) {
 // Content returned, do something with it

// Need to re-assign the next token returned
sessionToken = getLatestConfigurationResponse.nextPollConfigurationToken();

// Sleep for 15 seconds

I hope the above shared information is insightful to your query. In case if you have any questions regarding the AWS Java SDK, you can directly reach the Dev team by pulling an issue on the Github [2]. Also, in case if you have any question regarding the AWS AppConfig service itself, which is a capability of AWS Systems Manager, please feel free to create a support ticket with our premium support team.




profile picture
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions