use of org.komamitsu.fluency.NonRetryableException in project fluency by komamitsu.
the class AwsS3Sender method buildClient.
@VisibleForTesting
protected S3Client buildClient(S3ClientBuilder s3ClientBuilder) {
if (config.getEndpoint() != null) {
try {
URI uri = new URI(config.getEndpoint());
s3ClientBuilder.endpointOverride(uri);
} catch (URISyntaxException e) {
throw new NonRetryableException(String.format("Invalid endpoint. %s", config.getEndpoint()), e);
}
}
if (config.getRegion() != null) {
s3ClientBuilder.region(Region.of(config.getRegion()));
}
if (config.getAwsAccessKeyId() != null && config.getAwsSecretAccessKey() != null) {
AwsBasicCredentials credentials = AwsBasicCredentials.create(config.getAwsAccessKeyId(), config.getAwsSecretAccessKey());
s3ClientBuilder.credentialsProvider(StaticCredentialsProvider.create(credentials));
}
return s3ClientBuilder.build();
}
Aggregations