use of com.amazonaws.services.ec2.AmazonEC2 in project photon-model by vmware.
the class AWSRemoteCleanup method disassociateAndDeleteNetworkACLs.
private void disassociateAndDeleteNetworkACLs(String vpcId, AmazonEC2 usEastEc2Client) {
DescribeNetworkAclsRequest networkAclsRequest = new DescribeNetworkAclsRequest().withFilters(new Filter(VPC_KEY, Collections.singletonList(vpcId)));
DescribeNetworkAclsResult networkAclsResult = usEastEc2Client.describeNetworkAcls(networkAclsRequest);
networkAclsResult.getNetworkAcls().stream().filter(networkAcl -> !(networkAcl.getIsDefault())).forEach(networkAcl -> {
DeleteNetworkAclRequest deleteNetworkAclRequest = new DeleteNetworkAclRequest().withNetworkAclId(networkAcl.getNetworkAclId());
this.host.log("Terminating stale network acl: %s", networkAcl.getNetworkAclId());
usEastEc2Client.deleteNetworkAcl(deleteNetworkAclRequest);
});
}
use of com.amazonaws.services.ec2.AmazonEC2 in project photon-model by vmware.
the class TestUtils method getEC2SynchronousClient.
public static AmazonEC2 getEC2SynchronousClient(AuthCredentialsServiceState credentials, String region) {
ClientConfiguration configuration = AWSUtils.createClientConfiguration();
AWSStaticCredentialsProvider awsStaticCredentialsProvider = new AWSStaticCredentialsProvider(new BasicAWSCredentials(credentials.privateKeyId, EncryptionUtils.decrypt(credentials.privateKey)));
AmazonEC2ClientBuilder ec2ClientBuilder = AmazonEC2ClientBuilder.standard().withCredentials(awsStaticCredentialsProvider).withRegion(region).withClientConfiguration(configuration);
return ec2ClientBuilder.build();
}
use of com.amazonaws.services.ec2.AmazonEC2 in project iep by Netflix.
the class AwsClientFactoryTest method getInstanceName.
@Test
public void getInstanceName() throws Exception {
AwsClientFactory factory = new AwsClientFactory(config);
AmazonEC2 ec2 = factory.getInstance("ec2-test", AmazonEC2.class);
Assert.assertNotNull(ec2);
Assert.assertSame(ec2, factory.getInstance("ec2-test", AmazonEC2.class));
Assert.assertNotSame(ec2, factory.getInstance(AmazonEC2.class));
}
use of com.amazonaws.services.ec2.AmazonEC2 in project iep by Netflix.
the class AwsClientFactoryTest method newInstanceInterface.
@Test
public void newInstanceInterface() throws Exception {
AwsClientFactory factory = new AwsClientFactory(config);
AmazonEC2 ec2 = factory.newInstance(AmazonEC2.class);
Assert.assertNotNull(ec2);
}
use of com.amazonaws.services.ec2.AmazonEC2 in project cloudbreak by hortonworks.
the class AwsMetadataCollector method collectGroupMetaData.
private Collection<CloudVmMetaDataStatus> collectGroupMetaData(AuthenticatedContext ac, AmazonAutoScaling amazonASClient, AmazonEC2 amazonEC2Client, AmazonCloudFormation amazonCFClient, String groupName, Iterable<CloudInstance> cloudInstances) {
Collection<CloudVmMetaDataStatus> cloudVmMetaDataStatuses = new ArrayList<>();
String asGroupName = cloudFormationStackUtil.getAutoscalingGroupName(ac, amazonCFClient, groupName);
List<String> instanceIds = cloudFormationStackUtil.getInstanceIds(amazonASClient, asGroupName);
DescribeInstancesRequest instancesRequest = cloudFormationStackUtil.createDescribeInstancesRequest(instanceIds);
DescribeInstancesResult instancesResult = amazonEC2Client.describeInstances(instancesRequest);
// contains instances with instanceId
Map<String, CloudInstance> mapByInstanceId = mapByInstanceId(cloudInstances);
// contains instances with privateId (without instanceId)
Queue<CloudInstance> untrackedInstances = untrackedInstances(cloudInstances);
for (Reservation reservation : instancesResult.getReservations()) {
LOGGER.info("Number of instances found in reservation: {}", reservation.getInstances().size());
for (Instance instance : reservation.getInstances()) {
String instanceId = instance.getInstanceId();
CloudInstance cloudInstance = ensureInstanceTag(mapByInstanceId, instance, instanceId, untrackedInstances, amazonEC2Client);
if (cloudInstance != null) {
CloudInstanceMetaData md = new CloudInstanceMetaData(instance.getPrivateIpAddress(), instance.getPublicIpAddress());
CloudVmInstanceStatus cloudVmInstanceStatus = new CloudVmInstanceStatus(cloudInstance, InstanceStatus.CREATED);
CloudVmMetaDataStatus cloudVmMetaDataStatus = new CloudVmMetaDataStatus(cloudVmInstanceStatus, md);
cloudVmMetaDataStatuses.add(cloudVmMetaDataStatus);
}
}
}
return cloudVmMetaDataStatuses;
}
Aggregations