Home > Applications & Tools, Cloud Computing > Amazon Web Services: How to Get Volume Snapshots Including Others’

Amazon Web Services: How to Get Volume Snapshots Including Others’

February 18th, 2016 Leave a comment Go to comments

As I mentioned in my previous post, I started to play with Amazon Web Services, in particular its APIs. As part of the learning process, I tried to invoke different APIs to familiarize myself with their usages.

Most of the APIs worked as expected without much surprise until I called describeSnapshots() method to list all the volume snapshots under my account. Because I hadn’t created any snapshots, I did not expect to see any snapshot returned. But my code actually got me 10,933 volume snapshots.

Time to learn how to "Google" and manage your VMware and clouds in a fast and secure


I could not believe what had happened, so I ran the program a couple of times and got similar results, not exactly the same number of snapshots, but in the ball park. Because the number is different for different calls, it means the list was actually dynamically generated.

The following shows the first snapshot information. As you can see it’s created in 2008 and owned by Amazon itself. There are much more volume snapshots that are not owned by Amazon but other customers. Based on the data, we can easily apply data analysis for some interesting data points like: average volume size, average snapshots per customers using snapshot features, the ratio of encryption, etc.

Snapshot 1
 Details: {SnapshotId: snap-8af818e3,VolumeId: vol-e1ac4888,State: completed,StartTime: Wed Nov 19 04:15:17 PST 2008,Progress: 100%,OwnerId: 947081328633,Description: Business/Industry Summary (Windows),VolumeSize: 15,OwnerAlias: amazon,Tags: [],Encrypted: false,}

Here is the code that allows you to list the snapshots.

package org.doublecloud.awssample;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.ec2.model.DescribeSnapshotsResult;
import com.amazonaws.services.ec2.model.Snapshot;
public class AwsEc2ListSnapshots
  public static void main(String[] args) throws Exception
    AWSCredentials credentials = new PropertiesCredentials(AwsEc2Adapter.class.getResourceAsStream("/AwsCredentials.properties"));
    AmazonEC2 ec2 = new AmazonEC2Client(credentials);
    DescribeSnapshotsResult ssReq = ec2.describeSnapshots();
    int count = 1;
    for (Snapshot ss : ssReq.getSnapshots())
      System.out.println("Snapshot " + count   + "\n Details: " + ss);

I originally thought it was a security hole where other’s information leaked to me. As Anthony Elizondo(@complex) pointed out, Amazon allows user to mark an EBS snapshot public, thus it makes senses to get all these seemingly leaked data. Something worth learning more.

  1. No comments yet.
  1. No trackbacks yet.