use of com.amazonaws.services.ec2.AmazonEC2 in project photon-model by vmware.
the class AWSRemoteCleanup method deleteSubnets.
private void deleteSubnets(String vpcId, AmazonEC2 usEastEc2Client) {
DescribeSubnetsRequest subnetsRequest = new DescribeSubnetsRequest().withFilters(new Filter(VPC_KEY, Collections.singletonList(vpcId)));
DescribeSubnetsResult securityGroupsResult = usEastEc2Client.describeSubnets(subnetsRequest);
securityGroupsResult.getSubnets().forEach(subnet -> {
DeleteSubnetRequest deleteSubnetRequest = new DeleteSubnetRequest().withSubnetId(subnet.getSubnetId());
this.host.log("Terminating stale subnet: %s", subnet.getSubnetId());
usEastEc2Client.deleteSubnet(deleteSubnetRequest);
});
}
use of com.amazonaws.services.ec2.AmazonEC2 in project photon-model by vmware.
the class AWSRemoteCleanup method deleteStaleAwsVolumes.
@Test
public void deleteStaleAwsVolumes() {
AmazonEC2 usEastEc2Client = this.ec2Clients.get(US_EAST_1_TAG);
DescribeVolumesResult volumesResult = usEastEc2Client.describeVolumes();
List<Volume> volumeList = volumesResult.getVolumes();
for (Volume volume : volumeList) {
long volumeCreationTimeMicros = TimeUnit.MILLISECONDS.toMicros(volume.getCreateTime().getTime());
long timeDifference = Utils.getNowMicrosUtc() - volumeCreationTimeMicros;
if (timeDifference > TimeUnit.HOURS.toMicros(1) && volume.getState().equalsIgnoreCase("available")) {
this.host.log("Terminating stale volume: %s", volume.getVolumeId());
DeleteVolumeRequest deleteVolumeRequest = new DeleteVolumeRequest().withVolumeId(volume.getVolumeId());
usEastEc2Client.deleteVolume(deleteVolumeRequest);
}
}
}
use of com.amazonaws.services.ec2.AmazonEC2 in project checker-framework by typetools.
the class SimpleFalsePositive method test.
void test(AmazonEC2 ec2Client, String namePrefix) {
DescribeImagesRequest request = new DescribeImagesRequest().withOwners("martin").withFilters(Arrays.asList(new Filter("platform", Arrays.asList("windows")), new Filter("name", Arrays.asList(String.format("%s*", namePrefix)))));
DescribeImagesResult result = ec2Client.describeImages(request);
}
use of com.amazonaws.services.ec2.AmazonEC2 in project checker-framework by typetools.
the class Cve2 method correct1.
public static void correct1(AmazonEC2 client) {
DescribeImagesRequest request = new DescribeImagesRequest();
request.withFilters(new Filter("name").withValues(IMG_NAME));
request.withOwners("martin");
DescribeImagesResult result = client.describeImages(request);
}
use of com.amazonaws.services.ec2.AmazonEC2 in project checker-framework by typetools.
the class Cve2 method correct2.
public static void correct2(AmazonEC2 client) {
DescribeImagesRequest request = new DescribeImagesRequest();
request.withImageIds("myImageId");
DescribeImagesResult result = client.describeImages(request);
}
Aggregations