wallix / awless

A Mighty CLI for AWS
http://awless.io/
Apache License 2.0
4.98k stars 263 forks source link

Reverse sort and adding tags to output? #126

Closed deinspanjer closed 7 years ago

deinspanjer commented 7 years ago

Trying to get a handle on an explosion of snapshots. Would be useful to do a reverse sort on the Created column (for now, resorting [snicker] to running in csv output and then doing a | tac.

Also, any way to get the tags into the output?

simcap commented 7 years ago

Indeed a reverse sort flag will come in handy, so we will add it.

For the tags of a snapshot, we do sync them when fetching a snapshot. We do not display them as part of the listings, as we have not find a way to do so while keeping a readable listing output.

Although less scriptable, the snapshot's tags will be shown with the awless show output if I am not mistaken. For example: awless show snap-071573255d4a764ce.

Note: when running multiples times a listing to craft my output, I find very useful the global flag --local to avoid re-fetching everything each time. (Of course at least a sync or cmd triggering a sync should have been done). I even have an alias alias awl=awless --local.

simcap commented 7 years ago

You might know as well that you can filter by tags. Doing a awless ls -h:

...
--tag stringSlice         Filter EC2 resources given tags (case sensitive!). Ex: --tag Env=Production
--tag-key stringSlice     Filter EC2 resources given a tag key only (case sensitive!). Ex: --tag-key Env
--tag-value stringSlice   Filter EC2 resources given a tag value only (case sensitive!). Ex: --tag-value Staging
...

Also tags are so central to good AWS management that we will add other features around them. @deinspanjer If you have ideas let us know.

deinspanjer commented 7 years ago

Thanks, this is very helpful. One more that I hope is related enough to tag along as a comment.

I ran list instances, list volumes, list snapshots and copied each of those outputs into an Excel workbook. I then used COUNTIF and SUMIF to count up the number of snapshots per volume and the number of volumes per instance. This gives me a pretty good accounting for the bad actors and low hanging fruit.

I grabbed one of the volume ids and I wanted to get just the snapshots for that volume so I tried running a command that gave an error.

➜  aws git:(master) ✗ awless list snapshots --ids --filter Volume=vol-91f5176b
[error]   Invalid filter key 'Volume'. Expecting any of: ID, Name. (Note: filter keys/values are case insensitive)

Is it intended that if you use --ids, you can only filter on the ID or the Name?

simcap commented 7 years ago

As you noticed the --ids indeed cause the issue.

Can be classified as a defect, as it would be useful to output only the ids once all the processing has been done on the rows. We will fix that.

Also what you do to find the low hanging fruits seems a good candidate for an awless inspector. If you give me precise specification in another issue and if it is a valuable inspector (i.e. useful for other people) I will implement it or help you do it.

deinspanjer commented 7 years ago

That is a good point about the inspector. Let me take a look at the bucket sizer one and see what I can do. I'll open a new issue if I get stuck or have something to offer.

simcap commented 7 years ago

When you say I wanted to get just the snapshots for that volume, since the volume in our model is the parent of a snapshot, if you awless show a volume you should see in the # Relations section the snapshots children - if they are any (otherwise it is a bug). Ex:

awless show --local vol-00f2d4cea0738f55e

But as you see the output of the show command is not yet really scriptable or grepable.

deinspanjer commented 7 years ago

Yes, I do see the snaps listed for a volume. What I was missing was that the show instance doesn't list the volumes attached to it. The only mention of them is in the Depending on: section where it shows their aliases -- @instance.name[volume], @instance.name[volume]