Search in sources :

Example 91 with AmazonEC2

use of com.amazonaws.services.ec2.AmazonEC2 in project checker-framework by typetools.

the class Cve2 method correct3.

public static void correct3(AmazonEC2 client) {
    DescribeImagesRequest request = new DescribeImagesRequest();
    request.setExecutableUsers(Collections.singletonList("myUser1"));
    DescribeImagesResult result = client.describeImages(request);
}
Also used : DescribeImagesResult(com.amazonaws.services.ec2.model.DescribeImagesResult) DescribeImagesRequest(com.amazonaws.services.ec2.model.DescribeImagesRequest)

Example 92 with AmazonEC2

use of com.amazonaws.services.ec2.AmazonEC2 in project checker-framework by typetools.

the class MorePreciseFilters method withOwnerId.

void withOwnerId(AmazonEC2 ec2) {
    DescribeImagesRequest request = new DescribeImagesRequest().withFilters(new Filter("name", Arrays.asList("my_image_name")), new Filter("owner-id", Arrays.asList("12345")));
    DescribeImagesResult result = ec2.describeImages(request);
}
Also used : Filter(com.amazonaws.services.ec2.model.Filter) DescribeImagesResult(com.amazonaws.services.ec2.model.DescribeImagesResult) DescribeImagesRequest(com.amazonaws.services.ec2.model.DescribeImagesRequest)

Example 93 with AmazonEC2

use of com.amazonaws.services.ec2.AmazonEC2 in project checker-framework by typetools.

the class MorePreciseFilters method withFilterNameInList.

/* TODO: handle lists
  void ownerAliasList(AmazonEC2 ec2Client) {
      DescribeImagesRequest imagesRequest = new DescribeImagesRequest();
      List<Filter> imageFilters = new ArrayList<Filter>();
      imageFilters.add(new Filter().withName("owner-alias").withValues("microsoft"));
      ec2Client.describeImages(imagesRequest.withFilters(imageFilters)).getImages();
  }
  */
void withFilterNameInList(AmazonEC2 ec2Client) {
    DescribeImagesRequest request = new DescribeImagesRequest();
    request.setFilters(Collections.singletonList(new Filter().withName("image-id").withValues("12345")));
    DescribeImagesResult result = ec2Client.describeImages(request);
}
Also used : Filter(com.amazonaws.services.ec2.model.Filter) DescribeImagesResult(com.amazonaws.services.ec2.model.DescribeImagesResult) DescribeImagesRequest(com.amazonaws.services.ec2.model.DescribeImagesRequest)

Example 94 with AmazonEC2

use of com.amazonaws.services.ec2.AmazonEC2 in project checker-framework by typetools.

the class MorePreciseFilters method withName4.

void withName4(AmazonEC2 ec2Client) {
    DescribeImagesRequest request = new DescribeImagesRequest();
    request.withFilters(new Filter().withName("owner-id").withName("foo").withValues("12345"), new Filter("owner-id", Arrays.asList("12345")));
    DescribeImagesResult result = ec2Client.describeImages(request);
}
Also used : Filter(com.amazonaws.services.ec2.model.Filter) DescribeImagesResult(com.amazonaws.services.ec2.model.DescribeImagesResult) DescribeImagesRequest(com.amazonaws.services.ec2.model.DescribeImagesRequest)

Example 95 with AmazonEC2

use of com.amazonaws.services.ec2.AmazonEC2 in project SimianArmy by Netflix.

the class AWSClient method describeSnapshots.

/**
 * Describe a set of specific EBS snapshots.
 *
 * @param snapshotIds the snapshot ids
 * @return the snapshots
 */
public List<Snapshot> describeSnapshots(String... snapshotIds) {
    if (snapshotIds == null || snapshotIds.length == 0) {
        LOGGER.info(String.format("Getting all EBS snapshots in region %s.", region));
    } else {
        LOGGER.info(String.format("Getting EBS snapshotIds for %d ids in region %s.", snapshotIds.length, region));
    }
    AmazonEC2 ec2Client = ec2Client();
    DescribeSnapshotsRequest request = new DescribeSnapshotsRequest();
    // Set the owner id to self to avoid getting snapshots from other accounts.
    request.withOwnerIds(Arrays.<String>asList("self"));
    if (snapshotIds != null) {
        request.setSnapshotIds(Arrays.asList(snapshotIds));
    }
    DescribeSnapshotsResult result = ec2Client.describeSnapshots(request);
    List<Snapshot> snapshots = result.getSnapshots();
    LOGGER.info(String.format("Got %d EBS snapshots in region %s.", snapshots.size(), region));
    return snapshots;
}
Also used : AmazonEC2(com.amazonaws.services.ec2.AmazonEC2)

Aggregations

AmazonEC2 (com.amazonaws.services.ec2.AmazonEC2)65 Filter (com.amazonaws.services.ec2.model.Filter)25 Instance (com.amazonaws.services.ec2.model.Instance)20 DescribeImagesRequest (com.amazonaws.services.ec2.model.DescribeImagesRequest)17 DescribeImagesResult (com.amazonaws.services.ec2.model.DescribeImagesResult)15 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)12 Reservation (com.amazonaws.services.ec2.model.Reservation)12 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)10 AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)9 DescribeAddressesResult (com.amazonaws.services.ec2.model.DescribeAddressesResult)8 DescribeInstancesRequest (com.amazonaws.services.ec2.model.DescribeInstancesRequest)8 Tag (com.amazonaws.services.ec2.model.Tag)8 AWSCredentials (com.amazonaws.auth.AWSCredentials)6 DescribeAddressesRequest (com.amazonaws.services.ec2.model.DescribeAddressesRequest)6 PropertiesCredentials (com.amazonaws.auth.PropertiesCredentials)5 DescribeSecurityGroupsResult (com.amazonaws.services.ec2.model.DescribeSecurityGroupsResult)5 DisassociateAddressRequest (com.amazonaws.services.ec2.model.DisassociateAddressRequest)5 ReleaseAddressRequest (com.amazonaws.services.ec2.model.ReleaseAddressRequest)5 AmazonServiceException (com.amazonaws.AmazonServiceException)4