$opt->parse();
try {
    $key = empty($opt->key) ? getenv('AWS_ACCESS_KEY') : $opt->key;
    $secret = empty($opt->secret) ? getenv('AWS_SECRET_KEY') : $opt->secret;
    $region = empty($opt->region) ? getenv('AWS_REGION') : $opt->region;
    $instanceId = $opt->instance;
    $exclusions = empty($opt->exclude) ? array() : array_map('trim', explode(',', $opt->exclude));
    $dryRun = (bool) $opt->{'dry-run'};
    $client = Ec2Client::factory(array('key' => $key, 'secret' => $secret, 'region' => $region));
    $clientHelper = new Ec2ClientHelper($client);
    if (empty($instanceId)) {
        $hostname = gethostname() . '.';
        $instance = $clientHelper->getInstanceByHostname($hostname);
        $instanceId = $instance['InstanceId'];
    } else {
        $instance = $clientHelper->getInstanceById($instanceId);
    }
    $instanceName = $clientHelper->resolveInstanceName($instance);
    $console->writeLine("Creating snapshots of {$instanceName}");
    $volumes = $clientHelper->getVolumesByInstance($instanceId);
    if (count($volumes) === 0) {
        throw new Exception('No volumes found');
    }
    $toBackup = array();
    foreach ($volumes as $volume) {
        $attachment = $clientHelper->getVolumeAttachmentForInstance($volume['Attachments'], $instanceId);
        $volumeId = $attachment['VolumeId'];
        $device = $attachment['Device'];
        if (in_array($volumeId, $exclusions) || in_array($device, $exclusions)) {
            $console->writeLine("Excluding {$volumeId} on {$device}", Color::YELLOW);
        } else {