Closed monyth closed 8 years ago
Hello !
Right now, it isn't possible to clean with older than 10 days
, but it could be a nice feature...
But you can remove with a commit sha if it is a tag, you can try something like that :
amicleaner/cli.py --mapping-key tags --mapping-values commit_sha --keep-previous 1
I set keep-previous
to zero because I suppose you have only one AMI per commit
It won't work if you set keep-previous
to 0
. The tool forces history, the minimum value is 1
And you can delete with timestamp? When you use keep-previous with 10 that's mean you keep 10 last versions of AMI?
No, there isn't a timestamp yet ...
And the keep-previous
argument is indeed a way to preserve amis sorted on creation-date
for those who share a same tag.
For your use case, I think you can use the following syntax :
amicleaner/cli.py --mapping-key name --mapping-values test1 --keep-previous 2
Default values : ==>
mapping_key : name
mapping_values : ['test1']
keep_previous : 2
Retrieving AMIs to clean ...
AMIs to be removed:
+------------+------------+
| Group name | candidates |
+------------+------------+
| test1 | 11 |
+------------+------------+
Do you want to continue and remove 11 AMIs [y/N] ? :
It will regroup all the AMIs which have the same name, reverse sort them on the creation-date
, and remove until keep-previous
argument which is 4 by default.
You can add --full-report
option to have a verbose output and see what AMIs are candidates
The method work but I have an issue with delete which generate an error and stop.
In parallel the delete for AMI in error is done after each minutes.
Do you have the last version of the repo ? This issue has already been fixed I've just tested, and it works fine :smile:
amicleaner/cli.py --mapping-key name --mapping-values test1 --full-report --keep-previous 10
The last version of repo ? Where can I find info?
just a git clone of the project. But I think I understand what's happening here. AMI deregistering is asynchronous, and it is scheduled by AWS. In my case, the deregistering operation was done instantly so I was able to remove the related snapshot. Interesting ...
Same after git clone with last version I have same issue. 1 AMI id is deleted but not other. I have an error message and after script stopped.
Hello,
Do you think it's possible to delete AMI ID older than 10 days or with commit sha?