When running on an EC2 instance, you can avoid having to generate credentials using IAM instance profiles. This is safer because it allows for more precise role-based access control.
The solution would be to fall back to an InstanceProfileCredentialsProvider (example) when there are no credentials available.
See http://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-roles.html, http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html for more background.
When running on an EC2 instance, you can avoid having to generate credentials using IAM instance profiles. This is safer because it allows for more precise role-based access control.
The solution would be to fall back to an InstanceProfileCredentialsProvider (example) when there are no credentials available.
See http://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-roles.html, http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html for more background.