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");
}
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);
}
}
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);
}
}
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");
}
}
}
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;
}
Aggregations