/** * Construct a synchronous implementation of AmazonEC2 using the current builder configuration. * * @param params * Current builder configuration represented as a parameter object. * @return Fully configured implementation of AmazonEC2. */ @Override protected AmazonEC2 build(AwsSyncClientParams params) { return new AmazonEC2Client(params); }
@Provides @LazySingleton public AmazonEC2 getEc2Client(AWSCredentialsProvider credentials) { return new AmazonEC2Client(credentials); } }
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; }
/** * 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; }
@Override public AmazonEC2 get() { AmazonEC2Client amazonEC2 = new AmazonEC2Client(awsClusterSecurityManager.getCredentialsProvider()); amazonEC2.setRegion(region); return amazonEC2; } });
/** * @param accessKey * @param secretKey * @return */ public static AmazonEC2Client getEC2Client( String accessKey, String secretKey ) { AWSCredentialsProvider provider; if ( accessKey != null && secretKey != null ) { AWSCredentials credentials = new BasicAWSCredentials( accessKey, secretKey ); provider = new StaticCredentialsProvider( credentials ); } else { provider = new DefaultAWSCredentialsProviderChain(); } AmazonEC2Client client = new AmazonEC2Client( provider ); ClientConfiguration configuration = new ClientConfiguration(); configuration.setProtocol( Protocol.HTTPS ); client.setConfiguration( configuration ); return client; }
AmazonEC2Client ec2 = new AmazonEC2Client(new PersistS3.H2OAWSCredentialsProviderChain()); ec2.setEndpoint("ec2." + region + ".amazonaws.com"); DescribeInstancesResult describeInstancesResult = ec2.describeInstances();
/** * Construct a synchronous implementation of AmazonEC2 using the current builder configuration. * * @param params * Current builder configuration represented as a parameter object. * @return Fully configured implementation of AmazonEC2. */ @Override protected AmazonEC2 build(AwsSyncClientParams params) { return new AmazonEC2Client(params); }
@Provides @LazySingleton public AmazonEC2 getEc2Client(AWSCredentialsProvider credentials) { return new AmazonEC2Client(credentials); } }
@Provides @LazySingleton public AmazonEC2 getEc2Client(AWSCredentialsProvider credentials) { return new AmazonEC2Client(credentials); } }
@Override public void setIaasProperties(Map<String, String> iaasProperties) throws IaasException { // Check the properties parseProperties(iaasProperties ); this.iaasProperties = iaasProperties; // Configure the IaaS client AWSCredentials credentials = new BasicAWSCredentials( iaasProperties.get(Ec2Constants.EC2_ACCESS_KEY), iaasProperties.get(Ec2Constants.EC2_SECRET_KEY)); this.ec2 = new AmazonEC2Client( credentials ); this.ec2.setEndpoint( iaasProperties.get(Ec2Constants.EC2_ENDPOINT)); }
protected static AmazonEC2Client newAmazonEC2Client(EC2ServiceContext context) { if (context.getConfiguration().isPresent()) { return new AmazonEC2Client(context.getCredentials(), context.getConfiguration().get()); } else { return new AmazonEC2Client(context.getCredentials()); } }
private static AmazonEC2Client newEC2Client(String accessKey, String secretKey) { BasicAWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey); try { return new AmazonEC2Client(awsCredentials); } catch (AmazonServiceException e) { String err = "Could not create connection to Amazon EC2 due " + "to error: " + e.getMessage(); throw new EC2ConnectionException(err, e); } }
public GetASGName(String region, String instanceId) { super(NUMBER_OF_RETRIES, WAIT_TIME); this.region = region; this.instanceId = instanceId; client = new AmazonEC2Client(provider.getAwsCredentialProvider()); client.setEndpoint("ec2." + region + ".amazonaws.com"); }
@Override public AmazonEC2 get() { AmazonEC2Client amazonEC2 = new AmazonEC2Client(awsClusterSecurityManager.getCredentialsProvider()); amazonEC2.setRegion(region); return amazonEC2; } });
private static AmazonEC2 getEC2Client() { AmazonEC2 ec2 = new AmazonEC2Client(new BasicAWSCredentials(AmazonCredential.getInstance().getAwsAccessKeyId(), AmazonCredential.getInstance().getAwsSecretAccessKey())); return ec2; }
private static AmazonEC2 getEC2Client() { AmazonEC2 ec2 = new AmazonEC2Client(new BasicAWSCredentials(AmazonCredential.getInstance().getAwsAccessKeyId(), AmazonCredential.getInstance().getAwsSecretAccessKey())); return ec2; }
protected AmazonEC2 getCrossAccountEc2Client() { AmazonEC2 client = new AmazonEC2Client(crossAccountProvider.getAwsCredentialProvider()); client.setEndpoint("ec2." + envVariables.getRegion() + ".amazonaws.com"); return client; } }
AmazonEC2Client ec2Client = new AmazonEC2Client(); DescribeInstancesResult describeInstanceResult = ec2Client.describeInstances(); List<Reservation> reservations = describeInstanceResult.getReservations(); for (Reservation reservation : reservations) { for (Instance instance : reservation.getInstances()) { System.out.println(instance.getVpcId()); } }