User guide

To override the default credentials file location
Set the AWS_CREDENTIAL_FILE environment variable to the location of your AWS credentials file.
On Linux, OS X, or Unix, use export:
export AWS_CREDENTIAL_FILE=path/to/credentials_file
On Window, use set:
set AWS_CREDENTIAL_FILE=path/to/credentials_file
AWS Credentials File Format
When you create an AWS credentials file using the aws configure command, it creates a file with the
following format:
[default]
aws_access_key_id=YOUR_ACCESS_KEY_ID
aws_secret_access_key=YOUR_SECRET_ACCESS_KEY
[profile2]
...
The profile name is specified in square brackets (For example: [default]), followed by the configurable
fields in that profile as key/value pairs.You can have multiple profiles in your credentials file, which can
be added or edited using aws configure --profile PROFILE_NAME to select the profile to configure.
You can also specify additional fields, such as aws_session_token, metadata_service_timeout
and metadata_service_num_attempts.These are not configurable with the CLI — you must edit the
file by hand if you wish to use them. For more information about the configuration file and its available
fields, see the AWS CLI Reference.
Loading Credentials
Once credentials have been set, you can load them using the SDK for Java default credential provider
chain.
To load credentials using the default credential provider chain
Instantiate an AWS Service client using the default constructor. For example:
AmazonS3 s3Client = new AmazonS3Client();
Alternately, you can specify a new DefaultAWSCredentialsProviderChain in the client's constructor.
The following line of code is effectively equivalent to the preceding example:
AmazonS3 s3Client = new AmazonS3Client(new DefaultAWSCredentialsProviderCha
in());
Version v1.0.0
11
AWS SDK for Java Developer Guide
Using the Default Credential Provider Chain