Credentials set as environment variables

Set the environment variables AWS_ACCESS_KEY_ID to define the access key and AWS_SECRET_ACCESS_KEY to define the secret key.

If these variables are defined when the AmazonS3Client is created, the default constructor can be used.

Note: Setting environment variables varies by operating system. For more information, see this Knowledge Base Article.
Table 1. AWS Java SDK Supported Environmental Variables
Variable Purpose
AWS_ACCESS_KEY AWS access key.
AWS_SECRET_ACCESS_KEY AWS secret key. Access and secret key variables override credentials that are stored in both credential and config files.
AWS_SECURITY_TOKEN Security token. A web service that allows requests for temporary, limited-privilege credentials for AWS Identity and Access Management (IAM) users or for users that you authenticate (federated users).
AWS_PROFILE Name of the profile to use, such as the name of a profile that is stored in a credential or a config file. The default is to use the default profile.

Example: Setting and loading credentials using system Environment Variables

Assume the following environment variables are set:
AWS_ACCESS_KEY_ID=lDrDjH0D45hQivu6FNlwQ
AWS_SECRET_ACCESS_KEY=bHp5DOjg0HHJrGK7h3ejEqRDnVmWZK03T4lstel6

AmazonS3 s3Client = new AmazonS3Client(); 1

1 The AWS Java SDK automatically reads the Access Key ID and Secret Access Key from the 
  Environment Variables. They do not need to be provided explicitly.