Search in sources :

Example 1 with InstanceProfileCredentialsProvider

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);
    }
}
Also used : InstanceProfileCredentialsProvider(com.amazonaws.auth.InstanceProfileCredentialsProvider) AmazonAutoScalingClient(com.amazonaws.services.autoscaling.AmazonAutoScalingClient) ClientConfiguration(com.amazonaws.ClientConfiguration) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 2 with InstanceProfileCredentialsProvider

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();
}
Also used : InstanceProfileCredentialsProvider(com.amazonaws.auth.InstanceProfileCredentialsProvider) AssumeRoleRequest(com.amazonaws.services.securitytoken.model.AssumeRoleRequest) AWSSecurityTokenServiceClient(com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient) AssumeRoleResult(com.amazonaws.services.securitytoken.model.AssumeRoleResult) AWSSecurityTokenService(com.amazonaws.services.securitytoken.AWSSecurityTokenService)

Example 3 with InstanceProfileCredentialsProvider

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;
}
Also used : InstanceProfileCredentialsProvider(com.amazonaws.auth.InstanceProfileCredentialsProvider) AmazonCloudWatchClient(com.amazonaws.services.cloudwatch.AmazonCloudWatchClient)

Example 4 with InstanceProfileCredentialsProvider

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;
}
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 5 with InstanceProfileCredentialsProvider

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;
}
Also used : AmazonEC2Client(com.amazonaws.services.ec2.AmazonEC2Client) InstanceProfileCredentialsProvider(com.amazonaws.auth.InstanceProfileCredentialsProvider) AmazonEC2(com.amazonaws.services.ec2.AmazonEC2) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Aggregations

InstanceProfileCredentialsProvider (com.amazonaws.auth.InstanceProfileCredentialsProvider)6 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)4 ClientConfiguration (com.amazonaws.ClientConfiguration)2 AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)2 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)2 AmazonAutoScalingClient (com.amazonaws.services.autoscaling.AmazonAutoScalingClient)1 AmazonCloudWatchClient (com.amazonaws.services.cloudwatch.AmazonCloudWatchClient)1 AmazonRoute53Client (com.amazonaws.services.route53.AmazonRoute53Client)1 AWSSecurityTokenService (com.amazonaws.services.securitytoken.AWSSecurityTokenService)1 AWSSecurityTokenServiceClient (com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient)1 AssumeRoleRequest (com.amazonaws.services.securitytoken.model.AssumeRoleRequest)1 AssumeRoleResult (com.amazonaws.services.securitytoken.model.AssumeRoleResult)1