aws-amicleaner icon indicating copy to clipboard operation
aws-amicleaner copied to clipboard

Add an "-included-mapping-values" option

Open yogeek opened this issue 6 years ago • 0 comments

Hello,

First thank you for this useful tool :-) I would like to delete all AMIs with a tag "usage" equals to "test". Currently, as I think I understand the tool, it is not possible to do this. It is only possible to delete AMIs with specific tags (with --mapping-key tags --mapping-values <tag_names>) and to exclude some AMI that have a specific value for a tag (with -excluded-mapping-values <tag_values>.

It would be useful to add an option like "-included-mapping-values" to be able to delete AMIs that specifically matches some tag values. For example, with the current syntax, it could be like :

# Delete all AMIs with a tag "usage" equals to "test"
amicleaner --mapping-key tags --mapping-values usage -included-mapping-values test

# Delete all AMIs with a tag "usage" equals to "test" and a tag "env" equals to "stage"
amicleaner --mapping-key tags --mapping-values usage env -included-mapping-values test stage

# Delete all AMIs with a tag "usage" equals to "test" and a tag "env" equals to "stage" except those with a tag "keep" equals to "true"
amicleaner --mapping-key tags --mapping-values usage env -included-mapping-values test stage -excluded-mapping-values 

But the syntax can quickly become unconvenient for advanced request so I think that it will maybe be easier to pass to a key=value list for include or exclude (based on AWS filters syntax) :

amicleaner --include-filters name=aminame,tag:key1=value1,tag:key2=value2,... --exclude-filters tag:key3=value3,tag:key4=value4,...

Do you think it may be a good and feasible idea ? Thank you

yogeek avatar Jun 13 '18 08:06 yogeek