diff --git a/README.md b/README.md index ec02e97..84f09a8 100644 --- a/README.md +++ b/README.md @@ -1 +1,19 @@ +[![Build Status](https://travis-ci.org/NINEJKH/mamicleaner.svg?branch=master)](https://travis-ci.org/NINEJKH/mamicleaner) + # mamicleaner + +An AWS AMI cleanup tool that can work across multiple accounts. Heavily +inspired by [bonclay7/aws-amicleaner](https://github.com/bonclay7/aws-amicleaner) +and should most probably not yet be used in production. + +## Installation + +```bash +$ sudo curl -#fLo /usr/local/bin/mamicleaner https://github.com/NINEJKH/mamicleaner/releases/download/0.0.2/mamicleaner.phar && sudo chmod +x /usr/local/bin/mamicleaner +``` + +## Usage + +```bash +$ mamicleaner -pprofile1 -pprofile2 -Reu-west-2 ami:purge --filter-name=laravel --keep-previous 3 +``` diff --git a/app/Repositories/ImageRepository.php b/app/Repositories/ImageRepository.php index bd6e6af..107ce1a 100644 --- a/app/Repositories/ImageRepository.php +++ b/app/Repositories/ImageRepository.php @@ -34,19 +34,17 @@ public function findAll() public function delete(array $images) { foreach ($images as $image) { - //$this->persistence->deregisterImage([ - // 'ImageId' => $image['ImageId'], - //]); + $this->persistence->deregisterImage([ + 'ImageId' => $image['ImageId'], + ]); foreach ($image['BlockDeviceMappings'] as $blockDeviceMapping) { if (isset($blockDeviceMapping['Ebs']['SnapshotId'])) { - //$this->persistence->deleteSnapshot([ - // 'SnapshotId' => $blockDeviceMapping['Ebs']['SnapshotId'], - //]); - var_dump($blockDeviceMapping['Ebs']['SnapshotId']); + $this->persistence->deleteSnapshot([ + 'SnapshotId' => $blockDeviceMapping['Ebs']['SnapshotId'], + ]); } } } - } } diff --git a/cli.php b/cli.php index f885aba..2ea2844 100644 --- a/cli.php +++ b/cli.php @@ -9,8 +9,8 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Input\InputOption; -if (file_exists('version.txt')) { - $version = file_get_contents('version.txt'); +if (file_exists(__DIR__ . '/version.txt')) { + $version = file_get_contents(__DIR__ . '/version.txt'); } else { $version = 'dev'; }