aws-samples / aws-samples/aws-java-sample

Unable to load AWS credentials from any provider in the chain

Đang mở
#15 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
241
Fork
345
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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:
```try {
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:
```dynamoDBClient = builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(url, region.getName()))
.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?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.