use of com.amazonaws.auth.InstanceProfileCredentialsProvider in project eureka by Netflix.
the class AwsAsgUtil method getAmazonAutoScalingClient.
private AmazonAutoScaling getAmazonAutoScalingClient() {
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 AmazonAutoScalingClient(new BasicAWSCredentials(aWSAccessId, aWSSecretKey), clientConfiguration);
} else {
return new AmazonAutoScalingClient(new InstanceProfileCredentialsProvider(), clientConfiguration);
}
}
use of com.amazonaws.auth.InstanceProfileCredentialsProvider in project eureka by Netflix.
the class AwsAsgUtil method initializeStsSession.
private Credentials initializeStsSession(String asgAccount) {
AWSSecurityTokenService sts = new AWSSecurityTokenServiceClient(new InstanceProfileCredentialsProvider());
String region = clientConfig.getRegion();
if (!region.equals("us-east-1")) {
sts.setEndpoint("sts." + region + ".amazonaws.com");
}
String roleName = serverConfig.getListAutoScalingGroupsRoleName();
String roleArn = "arn:aws:iam::" + asgAccount + ":role/" + roleName;
AssumeRoleResult assumeRoleResult = sts.assumeRole(new AssumeRoleRequest().withRoleArn(roleArn).withRoleSessionName("sts-session-" + asgAccount));
return assumeRoleResult.getCredentials();
}
use of com.amazonaws.auth.InstanceProfileCredentialsProvider in project jmxtrans by jmxtrans.
the class CloudWatchWriter method createCloudWatchClient.
/**
* Configuring the CloudWatch client.
*
* Credentials are loaded from the Amazon EC2 Instance Metadata Service
*/
private AmazonCloudWatchClient createCloudWatchClient() {
AmazonCloudWatchClient cloudWatchClient = new AmazonCloudWatchClient(new InstanceProfileCredentialsProvider());
cloudWatchClient.setRegion(checkNotNull(Regions.getCurrentRegion(), "Problems getting AWS metadata"));
return cloudWatchClient;
}
use of com.amazonaws.auth.InstanceProfileCredentialsProvider 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;
}
use of com.amazonaws.auth.InstanceProfileCredentialsProvider 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;
}
Aggregations