Search in sources :

Example 1 with AmazonS3EncryptionClient

use of com.amazonaws.services.s3.AmazonS3EncryptionClient in project presto by prestodb.

the class PrestoS3FileSystem method createAmazonS3Client.

private AmazonS3Client createAmazonS3Client(URI uri, Configuration hadoopConfig, ClientConfiguration clientConfig) {
    AWSCredentialsProvider credentials = getAwsCredentialsProvider(uri, hadoopConfig);
    Optional<EncryptionMaterialsProvider> emp = createEncryptionMaterialsProvider(hadoopConfig);
    AmazonS3Client client;
    String signerType = hadoopConfig.get(S3_SIGNER_TYPE);
    if (signerType != null) {
        clientConfig.withSignerOverride(signerType);
    }
    if (emp.isPresent()) {
        client = new AmazonS3EncryptionClient(credentials, emp.get(), clientConfig, new CryptoConfiguration(), METRIC_COLLECTOR);
    } else {
        client = new AmazonS3Client(credentials, clientConfig, METRIC_COLLECTOR);
    }
    // use local region when running inside of EC2
    if (pinS3ClientToCurrentRegion) {
        Region region = Regions.getCurrentRegion();
        if (region != null) {
            client.setRegion(region);
        }
    }
    String endpoint = hadoopConfig.get(S3_ENDPOINT);
    if (endpoint != null) {
        client.setEndpoint(endpoint);
    }
    return client;
}
Also used : AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) AmazonS3EncryptionClient(com.amazonaws.services.s3.AmazonS3EncryptionClient) EncryptionMaterialsProvider(com.amazonaws.services.s3.model.EncryptionMaterialsProvider) KMSEncryptionMaterialsProvider(com.amazonaws.services.s3.model.KMSEncryptionMaterialsProvider) CryptoConfiguration(com.amazonaws.services.s3.model.CryptoConfiguration) Region(com.amazonaws.regions.Region) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider)

Aggregations

AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)1 Region (com.amazonaws.regions.Region)1 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)1 AmazonS3EncryptionClient (com.amazonaws.services.s3.AmazonS3EncryptionClient)1 CryptoConfiguration (com.amazonaws.services.s3.model.CryptoConfiguration)1 EncryptionMaterialsProvider (com.amazonaws.services.s3.model.EncryptionMaterialsProvider)1 KMSEncryptionMaterialsProvider (com.amazonaws.services.s3.model.KMSEncryptionMaterialsProvider)1