Back
Using this code for setting the classpath
AWSCredentialsProvider credentialsProvider = new ClasspathPropertiesFileCredentialsProvider();ec2 = new AmazonEC2Client(credentialsProvider);
AWSCredentialsProvider credentialsProvider = new ClasspathPropertiesFileCredentialsProvider();
ec2 = new AmazonEC2Client(credentialsProvider);
Below is the format for AwsCredentials.properties file
# Fill in your AWS Access Key ID and Secret Access Key# http://aws.amazon.com/security-credentialsaccessKey = key heresecretKey = secret key here
# Fill in your AWS Access Key ID and Secret Access Key
# http://aws.amazon.com/security-credentials
accessKey = key here
secretKey = secret key here
Below is the exception I am getting
Exception in thread "main" com.amazonaws.AmazonClientException: Unable to load AWS credentials from the /AwsCredentials.properties file on the classpath at com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider.getCredentials(ClasspathPropertiesFileCredentialsProvider.java:81) at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:8359)
Exception in thread "main" com.amazonaws.AmazonClientException: Unable to load AWS credentials from the /AwsCredentials.properties file on the classpath
at com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider.getCredentials(ClasspathPropertiesFileCredentialsProvider.java:81)
at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:8359)
The reason for this exception is because your AWS SDK is not able to load your credentials. Now, do this:
Preference → AWS → Add Secret key and Access key
This will allow your project to retrieve both the keys.
Learn how we helped 50,000+ professionals like you !
31k questions
32.8k answers
501 comments
693 users