Skip to content

Commit

Permalink
update billing
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Aug 22, 2025
1 parent 3750ce2 commit e1360c0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion inventory/get-billing.sh
Original file line number Diff line number Diff line change
@@ -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 ]
Expand Down Expand Up @@ -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

0 comments on commit e1360c0

Please sign in to comment.