まくろぐ
更新: / 作成:
aws ce get-cost-and-usage ...

次の例では、指定した期間の AWS 利用料金を求めています。

aws ce get-cost-and-usage \
    --granularity MONTHLY \
    --time-period Start=2021-01-01,End=2021-02-01 \
    --metrics BlendedCost
DimensionValueAttributes: []
ResultsByTime:
- Estimated: false
  Groups: []
  TimePeriod:
    End: '2021-02-01'
    Start: '2021-01-01'
  Total:
    BlendedCost:
      Amount: '0.0900932477'
      Unit: USD

次の例では、サービスごとに料金表示しています。

aws ce get-cost-and-usage \
    --granularity MONTHLY \
    --time-period Start=2021-01-01,End=2021-02-01 \
    --metrics BlendedCost \
    --group-by Type=DIMENSION,Key=SERVICE
DimensionValueAttributes: []
GroupDefinitions:
- Key: SERVICE
  Type: DIMENSION
ResultsByTime:
- Estimated: false
  Groups:
  - Keys:
    - AWS CloudShell
    Metrics:
      BlendedCost:
        Amount: '0.0000032477'
        Unit: USD
  - Keys:
    - AWS CodeCommit
    Metrics:
      BlendedCost:
        Amount: '0'
        Unit: USD
  - Keys:
    - AWS Key Management Service
    Metrics:
      BlendedCost:
        Amount: '0'
        Unit: USD
  - Keys:
    - AWS Lambda
    Metrics:
      BlendedCost:
        Amount: '0'
        Unit: USD
  - Keys:
    - Amazon Simple Notification Service
    Metrics:
      BlendedCost:
        Amount: '0'
        Unit: USD
  - Keys:
    - Amazon Simple Storage Service
    Metrics:
      BlendedCost:
        Amount: '0.00009'
        Unit: USD
  - Keys:
    - AmazonCloudWatch
    Metrics:
      BlendedCost:
        Amount: '0'
        Unit: USD
  - Keys:
    - CodeBuild
    Metrics:
      BlendedCost:
        Amount: '0.08'
        Unit: USD
  - Keys:
    - Tax
    Metrics:
      BlendedCost:
        Amount: '0.01'
        Unit: USD
  TimePeriod:
    End: '2021-02-01'
    Start: '2021-01-01'
  Total: {}

サービスごとにコストを一行でシンプルに表示します。

$ aws ce get-cost-and-usage \
    --granularity MONTHLY \
    --time-period Start=2021-01-01,End=2021-02-01
    --metrics BlendedCost \
    --group-by Type=DIMENSION,Key=SERVICE \
    --query 'ResultsByTime[0].Groups[*].[Keys[0], Metrics.BlendedCost.Amount]' \
    --output=text
AWS CloudShell  0.0000032477
AWS CodeCommit  0
AWS Key Management Service      0
AWS Lambda      0
Amazon Simple Notification Service      0
Amazon Simple Storage Service   0.00009
AmazonCloudWatch        0
CodeBuild       0.08
Tax     0.01

関連記事

まくろぐ
サイトマップまくへのメッセージ