Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clearing AMI without tag #69

Open
yaoweijie opened this issue Jan 25, 2018 · 3 comments
Open

Clearing AMI without tag #69

yaoweijie opened this issue Jan 25, 2018 · 3 comments

Comments

@yaoweijie
Copy link

image

is it possible to selected mapping-key = "no-tags"

@jmilliron
Copy link

Apparently not. Bummer.

@jamesinc
Copy link

jamesinc commented Jun 28, 2018

I think you could pipe the command output, something like

amicleaner --full-report | grep -woE "ami\-[0-9a-z]+" | xargs -L1 echo "aws ec2 deregister-image --image-id"

And then you could copy/paste the CLI commands back into a console.

I think after that you could then use amicleaner --check-orphans to clean up any associated snapshots.

Edit: just tried this and it all worked as above

@kvz
Copy link

kvz commented Sep 6, 2019

I think you can, by pointing the --mapping-key to name instead of tags, check out this example:

❯ amicleaner --full-report --keep-previous 10 --mapping-key name --mapping-values tosip

Default values : ==>
mapping_key : name
mapping_values : ['tosip']
excluded_mapping_values : []
keep_previous : 10
ami_min_days : -1

Retrieving AMIs to clean ...
tosip
+-----------------------+-------------------------------------------------+--------------------------+
|         AMI ID        |                     AMI Name                    |      Creation Date       |
+-----------------------+-------------------------------------------------+--------------------------+
| ami-02eabc57a5f347de1 |    tosip-main-14-ec2-ebs200-20181108T084515Z    | 2018-11-08T08:58:22.000Z |
| ami-0d24a5c4950e88866 |    tosip-main-14-ec2-ebs200-20181108T150902Z    | 2018-11-08T15:21:59.000Z |
| ami-0a5e8c0adb7f23435 |     tosip-main-14-ec2-ebs200-20181126T142411    | 2018-11-26T14:37:46.000Z |
...

It would appear that it does require you to know a (part of) the name of the instances you want to clean up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants