AWS SDK for Java Migration Guide
AWS SDK for Java 2.x Migration Guide

Credentials Provider Changes

Credentials Provider

This section provides a mapping of the name changes of credential provider classes and methods between versions 1.11.x and 2.x of the SDK for Java. The following also lists some of the key differences in the way credentials are processed by the SDK in version 2.x:

  • The default credentials provider loads system properties before environment variables in version 2.x. See Working with AWS Credentials in the AWS SDK for Java 2.x Developer Guide

  • The constructor method is replaced with the create or builder methods.

    DefaultCredentialsProvider.create();
  • Asynchronous refresh is no longer set by default. You must specify it with the builder of the credentials provider.

    ContainerCredentialsProvider provider = ContainerCredentialsProvider.builder() .asyncCredentialUpdateEnabled(true) .build();
  • You can specify a path to a custom profile file using the ProfileCredentialsProvier.builder().

    ProfileCredentialsProvider profile = ProfileCredentialsProvider.builder() .profileFile(ProfileFile.builder().content(Paths.get("myProfileFile.file")).build()) .build();
  • Profile file format has changed to more closely match the AWS CLI. See Configuring the AWS CLI in the AWS Command Line Interface User Guide for details.

Credentials Provider Changes Mapped between Versions 1.11.x and 2.x

Class name changes

1.11.x 2.x

com.amazonaws.auth.AWSCredentialsProvider

software.amazon.awssdk.auth.credentials.AwsCredentialsProvider

com.amazonaws.auth.DefaultAWSCredentialsProviderChain

software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider

com.amazonaws.auth.AWSStaticCredentialsProvider

software.amazon.awssdk.auth.credentials.StaticCredentialsProvider

com.amazonaws.auth.EnvironmentVariableCredentialsProvider

software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider

com.amazonaws.auth.SystemPropertiesCredentialsProvider

software.amazon.awssdk.auth.credentials.SystemPropertyCredentialsProvider

com.amazonaws.auth.ProfileCredentialsProvider

software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider

com.amazonaws.auth.ContainerCredentialsProvider

software.amazon.awssdk.auth.credentials.ContainerCredentialsProvider

com.amazonaws.auth.InstanceProfileCredentialsProvider

software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider

com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider

software.amazon.awssdk.services.sts.auth.StsAssumeRoleCredentialsProvider

com.amazonaws.auth.STSSessionCredentialsProvider

software.amazon.awssdk.services.sts.auth.StsGetSessionTokenCredentialsProvider

com.amazonaws.auth.WebIdentityFederationSessionCredentialsProvider

software.amazon.awssdk.services.sts.auth.StsAssumeRoleWithWebIdentityCredentialsProvider

com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper

software.amazon.awssdk.auth.credentials.ContainerCredentialsProvider

software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider

com.amazonaws.services.s3.S3CredentialsProviderChain

software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider

software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider

com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider

Not Supported

com.amazonaws.auth.PropertiesFileCredentialsProvider

Not Supported

Method name changes

1.11.x 2.x

AWSCredentialsProvider.getCredentials

AwsCredentialsProvider.resolveCredentials

DefaultAWSCredentialsProviderChain.getInstance

Not Supported

AWSCredentialsProvider.getInstance

Not Supported

AWSCredentialsProvider.refresh

Not Supported

Environment variable name changes

1.11.x 2.x

AWS_ACCESS_KEY

AWS_ACCESS_KEY_ID

AWS_SECRET_KEY

AWS_SECRET_ACCESS_KEY

AWS_CREDENTIAL_PROFILES_FILE

AWS_SHARED_CREDENTIALS_FILE

System property name changes

1.11.x 2.x

aws.secretKey

aws.secretAccessKey

com.amazonaws.sdk.disableEc2Metadata

aws.disableEc2Metadata

com.amazonaws.sdk.ec2MetadataServiceEndpointOverride

aws.ec2MetadataServiceEndpoint