Initialization
We need the AWS credentials to access Amazon Web Services for using the API tools. We will check out two ways to get an instance of com.amazonaws.auth.AWSCredentials:
- Using
BasicAWSCredentials - Using
ProfileCredentialsProvider
Using BasicAWSCredentials
BasicAWSCredentials is a vanilla flavor implementation class for providing the AWS credentials, which are the access key and the secret key:
// Class Variable
protected AWSCredentials credentials = null;
....
public void initializeAWSCredentials(){
credentials = new BasicAWSCredentials("ACCESS_ID", "SECRET_KEY");
}Replace ACCESS_ID and SECRET_KEY with your actual access id and secret key.
Using ProfileCredentialsProvider
ProfileCredentialsProvider provides AWSCredentials. It accesses the configuration file and looks for the named profile credentials. This helps in storing multiple credentials in the configuration file, and in using the profile based on the name provided by the application.
The configuration...