// terminates the instance.
private Snapshot createSnapshot() throws RunNodesException {
String instanceId = null;
try {
RunningInstance instance = getOnlyElement(concat(ec2Api.getInstanceApi().get().runInstancesInRegion(
regionId, null, imageId, 1, 1)));
instanceId = instance.getId();
assertTrue(runningTester.apply(instance), instanceId + "didn't achieve the state running!");
instance = getOnlyElement(concat(ec2Api.getInstanceApi().get().describeInstancesInRegion(regionId,
instanceId)));
BlockDevice device = instance.getEbsBlockDevices().get("/dev/sda1");
assertNotNull(device, "device: /dev/sda1 not present on: " + instance);
Snapshot snapshot = ec2Api.getElasticBlockStoreApi().get().createSnapshotInRegion(regionId,
device.getVolumeId());
snapshotsToDelete.add(snapshot.getId());
return snapshot;