Search in sources :

Example 36 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project SimianArmy by Netflix.

the class TestBasicContext method testIsAbleToUseProxyByConfiguration.

@Test
public void testIsAbleToUseProxyByConfiguration() {
    BasicSimianArmyContext ctx = new BasicSimianArmyContext("proxy.properties");
    ClientConfiguration awsClientConfig = ctx.getAwsClientConfig();
    Assert.assertEquals(awsClientConfig.getProxyHost(), "127.0.0.1");
    Assert.assertEquals(awsClientConfig.getProxyPort(), 80);
    Assert.assertEquals(awsClientConfig.getProxyUsername(), "fakeUser");
    Assert.assertEquals(awsClientConfig.getProxyPassword(), "fakePassword");
}
Also used : ClientConfiguration(com.amazonaws.ClientConfiguration) Test(org.testng.annotations.Test)

Example 37 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project eureka by Netflix.

the class AwsAsgUtil method retrieveAutoScalingGroupCrossAccount.

private AutoScalingGroup retrieveAutoScalingGroupCrossAccount(String asgAccount, String asgName) {
    logger.debug("Getting cross account ASG for asgName: " + asgName + ", asgAccount: " + asgAccount);
    Credentials credentials = stsCredentials.get(asgAccount);
    if (credentials == null || credentials.getExpiration().getTime() < System.currentTimeMillis() + 1000) {
        stsCredentials.put(asgAccount, initializeStsSession(asgAccount));
        credentials = stsCredentials.get(asgAccount);
    }
    ClientConfiguration clientConfiguration = new ClientConfiguration().withConnectionTimeout(serverConfig.getASGQueryTimeoutMs());
    AmazonAutoScaling autoScalingClient = new AmazonAutoScalingClient(new BasicSessionCredentials(credentials.getAccessKeyId(), credentials.getSecretAccessKey(), credentials.getSessionToken()), clientConfiguration);
    String region = clientConfig.getRegion();
    if (!region.equals("us-east-1")) {
        autoScalingClient.setEndpoint("autoscaling." + region + ".amazonaws.com");
    }
    DescribeAutoScalingGroupsRequest request = new DescribeAutoScalingGroupsRequest().withAutoScalingGroupNames(asgName);
    DescribeAutoScalingGroupsResult result = autoScalingClient.describeAutoScalingGroups(request);
    List<AutoScalingGroup> asgs = result.getAutoScalingGroups();
    if (asgs.isEmpty()) {
        return null;
    } else {
        return asgs.get(0);
    }
}
Also used : DescribeAutoScalingGroupsRequest(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest) AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) AmazonAutoScalingClient(com.amazonaws.services.autoscaling.AmazonAutoScalingClient) BasicSessionCredentials(com.amazonaws.auth.BasicSessionCredentials) AmazonAutoScaling(com.amazonaws.services.autoscaling.AmazonAutoScaling) DescribeAutoScalingGroupsResult(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult) Credentials(com.amazonaws.services.securitytoken.model.Credentials) BasicSessionCredentials(com.amazonaws.auth.BasicSessionCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 38 with ClientConfiguration

use of com.amazonaws.ClientConfiguration 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 39 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project ice by Netflix.

the class AwsUtils method init.

/**
     * This method must be called before all methods can be used.
     * @param credentialsProvider
     */
public static void init(AWSCredentialsProvider credentialsProvider) {
    awsCredentialsProvider = credentialsProvider;
    clientConfig = new ClientConfiguration();
    String proxyHost = System.getProperty("https.proxyHost");
    String proxyPort = System.getProperty("https.proxyPort");
    if (proxyHost != null && proxyPort != null) {
        clientConfig.setProxyHost(proxyHost);
        clientConfig.setProxyPort(Integer.parseInt(proxyPort));
    }
    s3Client = new AmazonS3Client(awsCredentialsProvider, clientConfig);
    securityClient = new AWSSecurityTokenServiceClient(awsCredentialsProvider, clientConfig);
    if (System.getProperty("EC2_REGION") != null && !"us-east-1".equals(System.getProperty("EC2_REGION"))) {
        if ("global".equals(System.getProperty("EC2_REGION"))) {
            s3Client.setEndpoint("s3.amazonaws.com");
        } else {
            s3Client.setEndpoint("s3-" + System.getProperty("EC2_REGION") + ".amazonaws.com");
        }
    }
}
Also used : AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) AWSSecurityTokenServiceClient(com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 40 with ClientConfiguration

use of com.amazonaws.ClientConfiguration in project camel by apache.

the class SnsEndpoint method createSNSClient.

/**
     * Provide the possibility to override this method for an mock implementation
     *
     * @return AmazonSNSClient
     */
AmazonSNS createSNSClient() {
    AmazonSNS client = null;
    ClientConfiguration clientConfiguration = null;
    boolean isClientConfigFound = false;
    if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
        clientConfiguration = new ClientConfiguration();
        clientConfiguration.setProxyHost(configuration.getProxyHost());
        clientConfiguration.setProxyPort(configuration.getProxyPort());
        isClientConfigFound = true;
    }
    if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) {
        AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
        if (isClientConfigFound) {
            client = new AmazonSNSClient(credentials, clientConfiguration);
        } else {
            client = new AmazonSNSClient(credentials);
        }
    } else {
        if (isClientConfigFound) {
            client = new AmazonSNSClient();
        } else {
            client = new AmazonSNSClient(clientConfiguration);
        }
    }
    return client;
}
Also used : AmazonSNSClient(com.amazonaws.services.sns.AmazonSNSClient) AWSCredentials(com.amazonaws.auth.AWSCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) ClientConfiguration(com.amazonaws.ClientConfiguration) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AmazonSNS(com.amazonaws.services.sns.AmazonSNS)

Aggregations

ClientConfiguration (com.amazonaws.ClientConfiguration)44 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)18 AWSCredentials (com.amazonaws.auth.AWSCredentials)12 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)6 AmazonClientException (com.amazonaws.AmazonClientException)3 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)3 AmazonDynamoDBClient (com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient)3 File (java.io.File)3 Configuration (org.apache.hadoop.conf.Configuration)3 Test (org.testng.annotations.Test)3 AmazonServiceException (com.amazonaws.AmazonServiceException)2 Protocol (com.amazonaws.Protocol)2 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)2 InstanceProfileCredentialsProvider (com.amazonaws.auth.InstanceProfileCredentialsProvider)2 AwsClientBuilder (com.amazonaws.client.builder.AwsClientBuilder)2 AmazonAutoScalingClient (com.amazonaws.services.autoscaling.AmazonAutoScalingClient)2 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)2 AmazonS3 (com.amazonaws.services.s3.AmazonS3)2 S3ClientOptions (com.amazonaws.services.s3.S3ClientOptions)2 TransferManager (com.amazonaws.services.s3.transfer.TransferManager)2