diff --git a/inventory/get-billing.sh b/inventory/get-billing.sh index ea7b42a..738bf4d 100755 --- a/inventory/get-billing.sh +++ b/inventory/get-billing.sh @@ -1,6 +1,6 @@ #!/bin/bash -VERSION="1.0.2" +VERSION="1.1.0" caller=$(tf-aws sts get-caller-identity --query 'Arn' 2> /dev/null) if [ $(echo $caller | grep -c aws-us-gov) != 0 ] @@ -32,4 +32,9 @@ tf-aws ce get-cost-and-usage \ grep ^BLEND setup/cost-usage.${lastmonth}_${nextmonth}.txt |\ awk '{t+=$2} END {print NR,t}' > setup/cost-usage.${lastmonth}_${nextmonth}.summary +jq -c '.ResultsByTime[] | .Groups[] | [.Keys[0],.Metrics.UnblendedCost.Amount,.Metrics.BlendedCost.Amount,.Metrics.UsageQuantity.Amount] | @csv' \ + setup/cost-usage.${lastmonth}_${nextmonth}.json |\ + sed -e 's/\\"//g' -e 's/"//g'|sort -t, -k 2 -nr \ + > setup/cost-usage.${lastmonth}_${nextmonth}.csv + exit 0