thegreenwebfoundation / green-cost-explorer

See how much of your cloud bill is spent on fossil fuels ,so you can do the right thing and switch. We're in a climate crisis, remember?
Apache License 2.0
171 stars 18 forks source link

Accept command line flags for setting dates, and ideally tags to filter by #9

Open mrchrisadams opened 5 years ago

mrchrisadams commented 5 years ago

Right now the we have hard coded dates for running checks.

There's a normal 1 year rolling window I think for cost explorer, but it would be nice to set the time bounds, like you can with the python cli.

For example, when you have this:

aws ce get-cost-and-usage --time-period Start=2018-08-01,End=2019-05-01 --granularity MONTHLY --metrics "BlendedCost" "UsageQuantity" --group-by Type=DIMENSION,Key=AZ

I would be good to do something to either use the same kinds of flags:

greencost --time-period Start=2018-08-01,End=2019-05-01

Or ideally use flags like so, which

I'm not sure what the convention is for node js, but if we know we only ever have maximum of today plus one year back, we might be able to have some sensible defaults to show the last year of spend analysis, or be able to set arbitrary figures like so:

greencost --time-period-start 2018-08-01 --time-period-end 2019-05-01

I'm not sure what the most command CLI tool for node is, but commander looks well documented, and is used by the Vue CLI, so there's code examples we can look to for seeing how different things are implemented

https://www.npmjs.com/package/commander

 Bonus bit

If filtering by tags is simple, then it gives us a nice way to restrict a query to a single project team.

https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_GetCostAndUsage.html#API_GetCostAndUsage_RequestSyntax

mrchrisadams commented 5 years ago

After chatting, we'll use meow, instead of commander.

Mapbox already use it, and well… better gifs.

mrchrisadams commented 5 years ago

After convo, we're punting the tag decisions till we have first part built, and see how ppl use it.

mrchrisadams commented 5 years ago

This is the API we agreed on

flags

IMG_20190815_154918

edsu commented 4 years ago

At the moment the utility throws an error since the dates that are hard coded request data that's more than 12 months ago, which the API does not support.

mrchrisadams commented 4 years ago

Thanks for changing the hard coding, @edsu.

I based on on the extra bits, I'm going to leave this open in the hope that me, or some kind soul from the internet is able to add the parsing of flags for specific dates 👍