Additional setup information - AWS SDK for Java 2.x

You can now use the Amazon S3 Transfer Manager (Developer Preview) in the AWS SDK for Java 2.x for accelerated file transfers. Give it a try and let us know what you think!

Additional setup information

This topic supplements the information in Setting up the AWS SDK for Java 2.x.

Set up credentials profiles

You can use more than one set of credentials in your application by setting up additional credentials profiles. Like the [default] profile, you can set up custom profiles to use programmatic access keys as credentials or to use temporary credentials.

To configure your own credentials profiles, use the shared credentials and config files. See the snippets below for example usage.

*A profile,*cloudwatch_metrics , configured in the credentials file to use a programmatic access key as credentials:

[cloudwatch_metrics] aws_access_key_id = your_access_key_id aws_secret_access_key = your_secret_access_key region = us-east-2

A profile, devuser, configured in the config file to use temporary credentials by assuming a role based on an Amazon Resource Name (ARN).

[profile devuser] role_arn = {region-arn}iam::123456789012:role/developers source_profile = dev-user region = {region_api_default} output = json

For an example using single sign-on (SSO) authentication, using AWS IAM Identity Center (successor to AWS Single Sign-On), see SSO Credentials in the AWS SDKs and Tools Reference Guide. In addition to config file changes, a dependency must be added to your project’s pom.xml file:

<dependency> <groupId></groupId> <artifactId>sso</artifactId> <version>xxx</version> </dependency>

For additional information about configuring the shared credentials and config files, see:

Set an alternate credentials file location

By default, the AWS SDK for Java looks for the credentials file at ~/.aws/credentials. To customize the location of the shared credentials file, set the AWS_SHARED_CREDENTIALS_FILE environment variable to an alternate location.

To set this variable on Linux, macOS, or Unix, use export:

export AWS_SHARED_CREDENTIALS_FILE=path/to/credentials_file

To set this variable on Windows, use set:

set AWS_SHARED_CREDENTIALS_FILE=path/to/credentials_file