use of com.hazelcast.spi.exception.NoCredentialsException in project hazelcast by hazelcast.
the class AwsDiscoveryStrategy method discoverNodes.
@Override
public Iterable<DiscoveryNode> discoverNodes() {
try {
Map<String, String> addresses = awsClient.getAddresses();
logResult(addresses);
List<DiscoveryNode> result = new ArrayList<>();
for (Map.Entry<String, String> entry : addresses.entrySet()) {
for (int port = portRange.getFromPort(); port <= portRange.getToPort(); port++) {
Address privateAddress = new Address(entry.getKey(), port);
Address publicAddress = new Address(entry.getValue(), port);
result.add(new SimpleDiscoveryNode(privateAddress, publicAddress));
}
}
return result;
} catch (NoCredentialsException e) {
if (!isKnownExceptionAlreadyLogged) {
LOGGER.warning("No AWS credentials found! Starting standalone. To use Hazelcast AWS discovery, configure" + " properties (access-key, secret-key) or assign the required IAM Role to your EC2 instance");
LOGGER.finest(e);
isKnownExceptionAlreadyLogged = true;
}
} catch (RestClientException e) {
if (e.getHttpErrorCode() == HTTP_FORBIDDEN) {
if (!isKnownExceptionAlreadyLogged) {
LOGGER.warning("AWS IAM Role Policy missing 'ec2:DescribeInstances' Action! Starting standalone.");
isKnownExceptionAlreadyLogged = true;
}
LOGGER.finest(e);
} else {
LOGGER.warning("Cannot discover nodes. Starting standalone.", e);
}
} catch (Exception e) {
LOGGER.warning("Cannot discover nodes. Starting standalone.", e);
}
return Collections.emptyList();
}
use of com.hazelcast.spi.exception.NoCredentialsException in project hazelcast by hazelcast.
the class AzureMetadataApi method accessToken.
String accessToken() {
try {
String urlString = String.format("%s/metadata/identity/oauth2/token?api-version=%s&resource=%s", endpoint, API_VERSION, RESOURCE);
String accessTokenResponse = callGet(urlString);
return extractAccessToken(accessTokenResponse);
} catch (Exception e) {
throw new NoCredentialsException("Error while fetching access token from Azure API using managed identity.", e);
}
}
Aggregations