Unable to load AWS credentials from any provider in the chain
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- aws, java
- Domain
- authentication, cloud
Research direction
Start with the Java snippets using DefaultAWSCredentialsProviderChain.getCredentials(), the DynamoDB builder, and ClientConfiguration proxy settings. Reproduce the credential-chain failure on EC2 and determine whether the missing behavior is in instance-role access, proxy configuration, or client setup; done means documenting a confirmed cause and a reproducible resolution.
Written by the indexing model from the issue text.
Description
I have my application running on EC2. Trying to access dynamoDB from my Java application. But for every operation, I get "Unable to load AWS credentials from any provider in the chain".
- I have added dynamoDB permissions in the IAM role that gets attached to EC2 instance
- And also configured EC2 to assume that role in trust relationship.
Code:
AWSCredentialsProvider provider = new DefaultAWSCredentialsProviderChain();
AWSCredentials credentials = provider.getCredentials();
if(credentials != null) {
LOG.info("Credentials Key: " + credentials.getAWSAccessKeyId());
LOG.info("Credentials secret: " + credentials.getAWSSecretKey());
}
} catch (Exception e) {
LOG.info("Exception in credentials cause:" + e.getCause() +";message: " + e.getMessage() +";stack: " +e.getStackTrace());
}
The getCredentials() line itself throws an Exception with message: "Unable to load AWS credentials from any provider in the chain".
If I do not try to get credentials here and pass it to the DynamoDB client:
.withClientConfiguration(clientConfig)
.build();```
Then it throws the same exception when I try to do any operation.
I tried setting up the proxy too:
```ClientConfiguration clientConfig = new ClientConfiguration();
clientConfig.setProxyHost("yyy");
clientConfig.setProxyPort(port);
clientConfig.setNonProxyHosts("xxx");
clientConfig.setProtocol(Protocol.HTTP);```
and then passing it while creating the client:
``` dynamoDBClient = builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(url, region.getName()))
.withCredentials(credentialProvider())
.withClientConfiguration(clientConfig)
.build();
But no success.
Can someone @here guide me what am I missing here?
- Dominant language
- Java
- Stars
- 241
- Forks
- 345
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aws-samples/aws-java-sample
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
-
Build Error Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Build Failure Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
aws-samples/aws-java-sample#25 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
aws-samples/aws-java-sample#24 · 1 comment · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
aws-samples/aws-java-sample#19 · 1 comment ·
All issues in aws-samples/aws-java-sample
Similar issues
-
bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
opensearch-project/ml-commons#5094 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
emitter:client:csharp feature
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
affects/8.10 affects/8.9 component/clients kind/bug likelihood/mid severity/mid
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Two open-case totals on one screen: the Programs tile says 15,858 and the nav badge says 15,868 Openbug frontend maui-pilot
Difficulty 2/5 1-3 hours Newbie friendliness 72/100