use of com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper in project crate by crate.
the class S3Service method buildCredentials.
// pkg private for tests
static AWSCredentialsProvider buildCredentials(Logger logger, S3ClientSettings clientSettings) {
final AWSCredentials credentials = clientSettings.credentials;
if (credentials == null) {
logger.debug("Using instance profile credentials");
var ec2ContainerCredentialsProviderWrapper = new EC2ContainerCredentialsProviderWrapper();
try {
// Check if credentials are available
ec2ContainerCredentialsProviderWrapper.getCredentials();
return ec2ContainerCredentialsProviderWrapper;
} catch (SdkClientException e) {
throw new InvalidArgumentException("Cannot find required credentials to create a repository of type s3. " + "Credentials must be provided either as repository options access_key and secret_key or AWS IAM roles.");
}
} else {
logger.debug("Using basic key/secret credentials");
return new AWSStaticCredentialsProvider(credentials);
}
}
Aggregations