AWS CLI(Cost Explorer)

https://qiita.com/shinsaka/items/c368c403935549b4401b
https://dev.classmethod.jp/articles/road-to-jq-master-apprentice/

 

※1リクエスト当たり0.01ドル課金される

コスト合計
aws ce get-cost-and-usage \
--time-period Start=2020-08-01,End=2020-09-01 \
--granularity MONTHLY \
--metrics "BlendedCost"

aws ce get-cost-and-usage \
--time-period Start=2020-08-01,End=2020-09-01 \
--granularity MONTHLY \
--metrics "BlendedCost" \
| jq -c '.ResultsByTime.Total.BlendedCost.Amount '

 


サービス別コスト
aws ce get-cost-and-usage \
--time-period Start=2020-08-01,End=2020-09-01 \
--granularity MONTHLY \
--metrics "BlendedCost" \
--group-by Type=DIMENSION,Key=SERVICE

 

aws ce get-cost-and-usage \
--time-period Start=2020-08-01,End=2020-09-01 \
--granularity MONTHLY \
--metrics "BlendedCost" \
--group-by Type=DIMENSION,Key=SERVICE \
| jq -c '.ResultsByTime.Groups | { (.Keys) : .Metrics.BlendedCost.Amount} '


5ドル以上のサービス
aws ce get-cost-and-usage \
--time-period Start=2020-08-01,End=2020-09-01 \
--granularity MONTHLY \
--metrics "BlendedCost" \
--group-by Type=DIMENSION,Key=SERVICE \
| jq -c '.ResultsByTime.Groups | { (.Keys[]) : .Metrics.BlendedCost.Amount} ' \
| sed -e 's/{//g' -e 's/"//g' -e 's/}//g' \
| awk -F: '$2>=5{print $0}'