Skip to content

Commit

Permalink
live-run (#4)
Browse files Browse the repository at this point in the history
--
  • Loading branch information
lifeofguenter authored Dec 13, 2017
1 parent 3868746 commit 25202ad
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
14 changes: 6 additions & 8 deletions app/Repositories/ImageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
]);
}
}
}

}
}
4 changes: 2 additions & 2 deletions cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down

0 comments on commit 25202ad

Please sign in to comment.