Search in sources :

Example 26 with BasicAWSCredentials

use of com.amazonaws.auth.BasicAWSCredentials in project eureka by Netflix.

the class EIPManager method getEC2Service.

/**
     * Gets the EC2 service object to call AWS APIs.
     *
     * @return the EC2 service object to call AWS APIs.
     */
private AmazonEC2 getEC2Service() {
    String aWSAccessId = serverConfig.getAWSAccessId();
    String aWSSecretKey = serverConfig.getAWSSecretKey();
    AmazonEC2 ec2Service;
    if (null != aWSAccessId && !"".equals(aWSAccessId) && null != aWSSecretKey && !"".equals(aWSSecretKey)) {
        ec2Service = new AmazonEC2Client(new BasicAWSCredentials(aWSAccessId, aWSSecretKey));
    } else {
        ec2Service = new AmazonEC2Client(new InstanceProfileCredentialsProvider());
    }
    String region = clientConfig.getRegion();
    region = region.trim().toLowerCase();
    ec2Service.setEndpoint("ec2." + region + ".amazonaws.com");
    return ec2Service;
}
Also used : AmazonEC2Client(com.amazonaws.services.ec2.AmazonEC2Client) InstanceProfileCredentialsProvider(com.amazonaws.auth.InstanceProfileCredentialsProvider) AmazonEC2(com.amazonaws.services.ec2.AmazonEC2) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 27 with BasicAWSCredentials

use of com.amazonaws.auth.BasicAWSCredentials in project eureka by Netflix.

the class ElasticNetworkInterfaceBinder method getEC2Service.

private AmazonEC2 getEC2Service() {
    String aWSAccessId = serverConfig.getAWSAccessId();
    String aWSSecretKey = serverConfig.getAWSSecretKey();
    AmazonEC2 ec2Service;
    if (null != aWSAccessId && !"".equals(aWSAccessId) && null != aWSSecretKey && !"".equals(aWSSecretKey)) {
        ec2Service = new AmazonEC2Client(new BasicAWSCredentials(aWSAccessId, aWSSecretKey));
    } else {
        ec2Service = new AmazonEC2Client(new InstanceProfileCredentialsProvider());
    }
    String region = clientConfig.getRegion();
    region = region.trim().toLowerCase();
    ec2Service.setEndpoint("ec2." + region + ".amazonaws.com");
    return ec2Service;
}
Also used : AmazonEC2Client(com.amazonaws.services.ec2.AmazonEC2Client) InstanceProfileCredentialsProvider(com.amazonaws.auth.InstanceProfileCredentialsProvider) AmazonEC2(com.amazonaws.services.ec2.AmazonEC2) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 28 with BasicAWSCredentials

use of com.amazonaws.auth.BasicAWSCredentials in project eureka by Netflix.

the class Route53Binder method getAmazonRoute53Client.

private AmazonRoute53Client getAmazonRoute53Client(EurekaServerConfig serverConfig) {
    String aWSAccessId = serverConfig.getAWSAccessId();
    String aWSSecretKey = serverConfig.getAWSSecretKey();
    ClientConfiguration clientConfiguration = new ClientConfiguration().withConnectionTimeout(serverConfig.getASGQueryTimeoutMs());
    if (null != aWSAccessId && !"".equals(aWSAccessId) && null != aWSSecretKey && !"".equals(aWSSecretKey)) {
        return new AmazonRoute53Client(new BasicAWSCredentials(aWSAccessId, aWSSecretKey), clientConfiguration);
    } else {
        return new AmazonRoute53Client(new InstanceProfileCredentialsProvider(), clientConfiguration);
    }
}
Also used : InstanceProfileCredentialsProvider(com.amazonaws.auth.InstanceProfileCredentialsProvider) ClientConfiguration(com.amazonaws.ClientConfiguration) AmazonRoute53Client(com.amazonaws.services.route53.AmazonRoute53Client) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 29 with BasicAWSCredentials

use of com.amazonaws.auth.BasicAWSCredentials in project presto by prestodb.

the class PrestoS3FileSystem method getAwsCredentials.

private static Optional<AWSCredentials> getAwsCredentials(URI uri, Configuration conf) {
    String accessKey = conf.get(S3_ACCESS_KEY);
    String secretKey = conf.get(S3_SECRET_KEY);
    String userInfo = uri.getUserInfo();
    if (userInfo != null) {
        int index = userInfo.indexOf(':');
        if (index < 0) {
            accessKey = userInfo;
        } else {
            accessKey = userInfo.substring(0, index);
            secretKey = userInfo.substring(index + 1);
        }
    }
    if (isNullOrEmpty(accessKey) || isNullOrEmpty(secretKey)) {
        return Optional.empty();
    }
    return Optional.of(new BasicAWSCredentials(accessKey, secretKey));
}
Also used : BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 30 with BasicAWSCredentials

use of com.amazonaws.auth.BasicAWSCredentials in project exhibitor by soabase.

the class S3ClientImpl method changeCredentials.

@Override
public void changeCredentials(S3Credential credential, S3ClientConfig clientConfig) {
    RefCountedClient newRefCountedClient = (credential != null) ? new RefCountedClient(createClient(null, new BasicAWSCredentials(credential.getAccessKeyId(), credential.getSecretAccessKey()), clientConfig)) : new RefCountedClient(createClient(null, null, clientConfig));
    RefCountedClient oldRefCountedClient = client.getAndSet(newRefCountedClient);
    if (oldRefCountedClient != null) {
        oldRefCountedClient.markForDelete();
    }
}
Also used : BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Aggregations

BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)42 AWSCredentials (com.amazonaws.auth.AWSCredentials)25 ClientConfiguration (com.amazonaws.ClientConfiguration)16 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)10 AmazonClientException (com.amazonaws.AmazonClientException)5 InstanceProfileCredentialsProvider (com.amazonaws.auth.InstanceProfileCredentialsProvider)4 DefaultAWSCredentialsProviderChain (com.amazonaws.auth.DefaultAWSCredentialsProviderChain)3 PropertiesCredentials (com.amazonaws.auth.PropertiesCredentials)3 AmazonDynamoDBClient (com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient)3 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)3 AmazonS3 (com.amazonaws.services.s3.AmazonS3)3 AmazonSimpleDBClient (com.amazonaws.services.simpledb.AmazonSimpleDBClient)3 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)2 ProfileCredentialsProvider (com.amazonaws.auth.profile.ProfileCredentialsProvider)2 StaticCredentialsProvider (com.amazonaws.internal.StaticCredentialsProvider)2 Region (com.amazonaws.regions.Region)2 AmazonCloudWatchClient (com.amazonaws.services.cloudwatch.AmazonCloudWatchClient)2 AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)2 AmazonGlacierClient (com.amazonaws.services.glacier.AmazonGlacierClient)2 AmazonKinesisClient (com.amazonaws.services.kinesis.AmazonKinesisClient)2