How to fix no region or no credentials found errors when using aws sdk apis

com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain
com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
AmazonDynamoDB ddb = AmazonDynamoDBClientBuilder.defaultClient();
  1. Environment variablesAWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
  2. Java system propertiesaws.accessKeyId and aws.secretKey
  3. Web Identity Token credentials from the environment or container.
  4. The default credential profiles file– typically located at ~/.aws/credentials
  5. Amazon ECS container credentials
  6. Instance profile credentials
System.getenv("AWS_ACCESS_KEY_ID")
System.getProperty("aws.accessKeyId")
# lists all the existing profiles.
aws configure list
ps -ef
chown x /home/x/.aws

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store