Closed rquadling closed 7 years ago
Hi !
If I understand correctly what you want to do, I think yes it's possible.
You can specify that you want to group your AMIs based on the tags, with all the tags you provide, the tool will match all the AMIs with the same Tags keys and values together and then regroup them.
Let's say I have 3 AMIs : 2 test-1
, and 1 test-1
, all with the same SourceAmi
tag.
The following run :
amicleaner --full-report --mapping-key tags --mapping-values SourceAmi Name --keep-previous 0
will result with this :
ami-ed82e39e.test-1
+--------------+-----------------------+--------------------------+
| AMI ID | AMI Name | Creation Date |
+--------------+-----------------------+--------------------------+
| ami-0badf878 | gatling-61e878a | 2016-11-03T10:45:49.000Z |
| ami-86d287f5 | gatling-8d2c6bc | 2016-11-03T13:09:10.000Z |
+--------------+-----------------------+--------------------------+
test-2
+--------------+-----------------------+--------------------------+
| AMI ID | AMI Name | Creation Date |
+--------------+-----------------------+--------------------------+
| ami-c398afa5 | gatling-61e878a | 2017-03-15T17:01:13.000Z |
+--------------+-----------------------+--------------------------+
AMIs to be removed:
+---------------------+------------+
| Group name | candidates |
+---------------------+------------+
| ami-ed82e39e.test-1 | 2 |
| test-2 | 1 |
+---------------------+------------+
please let me know
The tags are custom tags, not named AMIs. All the AMIs are named based upon the nature of their use (i.e. app, cron, etc.), not upon the expected environment.
As an example, these are the tags I have for a production-master AMI
Actually, the Name
I used in my example is a tag, like most of AWS resources. Go ahead and try to give the custom tag keys you want to filter on.
Hi.
We tag our builds with a tag called
BuildTag
using one of these methods:production-master
andstaging-master
.bang-brown-sun
,loll-lowly-twig
, etc.In addition, we also tag them with
BuiltFor
which will beproduction
orstaging
.The
BuildTag
is determined from the names of the branches of code being deployed in that image. We have 5 code bases that a developer can pick and choose for deploying to staging for test or demonstration purposes, prior to the code being merged to that projects master branch. Each combination of the branches will generate a differentBuildTag
value.What we would like to be able to do is to be able to have our AMI counts as follow:
For a single
BuildTag
, no more than 5 AMIs. For a singleBuiltFor
, no more than 20 AMIs.So, as build_tag of production_master is built_for production, there will only be 5 AMIs available. But for our staging builds (which have the different build_tags), each tag would only have 5 AMIs available, but overall, no more than 20.
Is this possible with the amicleaner?