my opinion is my own

AWSの使用コストで割合が多い使用タイプをAWS CLIで出力する

これはCost Explolerのグループ化の条件で使用タイプを選択することで内訳を確認が出来る

image-20220130210536361

さっさと確認したい場合は、AWS CLIで下記を実行する

aws ce get-cost-and-usage \
    --time-period Start=2022-01-01,End=2022-01-30 \
    --granularity MONTHLY  \
    --metrics UnblendedCost \
    --group-by Type=DIMENSION,Key=USAGE_TYPE | jq -r '.ResultsByTime[].Groups[] | [(.Keys[]), .Metrics.UnblendedCost.Amount] | @csv' | awk -F\" '{print $2,$3,$4}'  | sort -r -V -k 2 | head -n 20

実行結果

[ec2-user@bastin ~]$ aws ce get-cost-and-usage \
>     --time-period Start=2022-01-01,End=2022-01-30 \
>     --granularity MONTHLY  \
>     --metrics UnblendedCost \
>     --group-by Type=DIMENSION,Key=USAGE_TYPE | jq -r '.ResultsByTime[].Groups[] | [(.Keys[]), .Metrics.UnblendedCost.Amount] | @csv' | awk -F\" '{print $2,$3,$4}'  | sort -r -V -k 2 | head -n 20
APN1-NatGateway-Hours , 85.932
APN1-BoxUsage:m5.large , 85.932
APN1-Aurora:BackupUsage , 71.7980427228
APN1-EBS:VolumeUsage.gp3 , 61.2496773819
APN1-VpcEndpoint-Hours , 58.212
APN1-BoxUsage:t3.medium , 37.6992
APN1-LoadBalancerUsage , 33.6798
APN1-CW:Canary-runs , 28.0288
APN1-BoxUsage:t2.micro , 21.0672
APN1-Node:ra3.4xlarge , 18.342470776
APN1-BoxUsage:t3.large , 15.5833333696
APN1-EBS:VolumeUsage.gp2 , 14.5525795272
APN1-TimedStorage-ByteHrs , 12.0382298307
APN1-RDS:ChargedBackupUsage , 11.442173008
APN1-CW:MetricMonitorUsage , 7.2927419734
APN1-PaidEventsRecorded , 7.23436
USE1-IM-ResponsePlan-Months-Tier1 , 7
APN1-BackupUsage , 6.6523140684
ap-northeast-1-KMS-Keys , 5.580645072
APN1-PaidComplianceCheck , 5.619
---

関連しているかもしれない記事


#AWS