Example usage for com.amazonaws.auth InstanceProfileCredentialsProvider getInstance

List of usage examples for com.amazonaws.auth InstanceProfileCredentialsProvider getInstance

Introduction

In this page you can find the example usage for com.amazonaws.auth InstanceProfileCredentialsProvider getInstance.

Prototype

public static InstanceProfileCredentialsProvider getInstance() 

Source Link

Document

Returns a singleton InstanceProfileCredentialsProvider that does not refresh credentials asynchronously.

Usage

From source file:com.facebook.presto.hive.s3.PrestoS3ClientFactory.java

License:Apache License

private AWSCredentialsProvider getAwsCredentialsProvider(Configuration conf, HiveS3Config defaults) {
    Optional<AWSCredentials> credentials = getAwsCredentials(conf);
    if (credentials.isPresent()) {
        return new AWSStaticCredentialsProvider(credentials.get());
    }//from  w  ww  .j  a va 2  s .  c o m

    boolean useInstanceCredentials = conf.getBoolean(S3_USE_INSTANCE_CREDENTIALS,
            defaults.isS3UseInstanceCredentials());
    if (useInstanceCredentials) {
        return InstanceProfileCredentialsProvider.getInstance();
    }

    String providerClass = conf.get(S3_CREDENTIALS_PROVIDER);
    if (!isNullOrEmpty(providerClass)) {
        return getCustomAWSCredentialsProvider(conf, providerClass);
    }

    throw new RuntimeException("S3 credentials not configured");
}

From source file:com.thinkbiganalytics.kylo.catalog.aws.S3FileSystemProvider.java

License:Apache License

/**
 * Creates an S3 client with the standard credential providers.
 *///from   w w  w  .j a v  a  2s .  c  o m
@VisibleForTesting
protected AmazonS3 createS3Client(@Nonnull final URI uri, @Nonnull final Configuration conf) {
    // Create list of credential providers
    final List<AWSCredentialsProvider> credentials = new ArrayList<>();
    getCustomCredentialsProvider(uri, conf).ifPresent(credentials::add);
    getBasicCredentialsProvider(uri, conf).ifPresent(credentials::add);
    credentials.add(InstanceProfileCredentialsProvider.getInstance());

    // Create client
    final AWSCredentialsProviderChain chain = new AWSCredentialsProviderChain(credentials);
    chain.setReuseLastProvider(true);
    return AmazonS3ClientBuilder.standard().withCredentials(chain).build();
}

From source file:io.prestosql.plugin.hive.s3.PrestoS3FileSystem.java

License:Apache License

private AWSCredentialsProvider createAwsCredentialsProvider(URI uri, Configuration conf) {
    Optional<AWSCredentials> credentials = getAwsCredentials(uri, conf);
    if (credentials.isPresent()) {
        return new AWSStaticCredentialsProvider(credentials.get());
    }/*  w ww  . j  av a  2  s .  c o m*/

    if (useInstanceCredentials) {
        return InstanceProfileCredentialsProvider.getInstance();
    }

    String providerClass = conf.get(S3_CREDENTIALS_PROVIDER);
    if (!isNullOrEmpty(providerClass)) {
        return getCustomAWSCredentialsProvider(uri, conf, providerClass);
    }

    throw new RuntimeException("S3 credentials not configured");
}