项目作者: rocketmiles

项目描述 :
AWS Cost Comparison Tool
高级语言: Go
项目地址: git://github.com/rocketmiles/aws-cct.git
创建时间: 2020-10-26T19:34:42Z
项目社区:https://github.com/rocketmiles/aws-cct

开源协议:MIT License

下载


AWS Cost Comparison Tool

This is a simple CLI tool that wraps the AWS Cost Explorer APIs to be able to quickly identify cost anomalies between monthly bills.

Use Cases

  • Comparing costs between two different months
  • Creating a CSV report to show changes in the bill
  • Diagnosing which specific line item changed the most to identify anomalies

Requirements

  • AWS Credentials Setup locally
  • Access to Cost Explorer APIs (ce:*)

Installation

Homebrew

  1. brew tap rocketmiles/aws-cct https://github.com/rocketmiles/aws-cct
  2. brew install aws-cct

Updating

  1. brew upgrade aws-cct

Through GitHub

Download from the releases

Go Get

  1. go get github.com/rocketmiles/aws-cct

Usage

For full usage, see the help page with aws-cct help:

  1. NAME:
  2. aws-cct - AWS Cost Comparison Tool
  3. USAGE:
  4. aws-cct [global options] command [command options] [arguments...]
  5. COMMANDS:
  6. help, h Shows a list of commands or help for one command
  7. GLOBAL OPTIONS:
  8. --start value First month to compare (2020-01-01) (default: "2021-09-01")
  9. --end value Second month to compare (2020-02-01) (default: "2021-10-01")
  10. --cost-metric value Cost Metric to compare (NetAmortizedCost, UnblendedCost, etc.) (default: "NetAmortizedCost")
  11. --service value Define a service to dig into
  12. --tag value Tag value to filter results (app=web, env=prod, etc.)
  13. --sort value Column to sort results on (name, start, end, delta, deltapercent) (default: "name")
  14. --sort-order value Order to sort in (asc or desc) (default: "asc")
  15. --output value Output format (supported formats: table, csv) (default: "table")
  16. --help, -h show help (default: false)

Simple usage

  1. aws-cct

Check Unblended Costs

  1. aws-cct --cost-metric UnblendedCost

Dig into EC2 costs

You can get the string from the initial output. Simply copy the value in the “SERVICE” section and you can filter into that

  1. aws-cct --service "Amazon Elastic Compute Cloud - Compute"

Filter by tags

You can get filter costs by tag, to return costs for resources that match all specified tag values.

  1. aws-cct --tag app=widgetizer --tag env=production

Compare Older Months

  1. aws-cct --start 2020-08-01 --end 2020-09-01

Sort on a column

You can sort on any column, ascending or descending, for example to see the largest deltas first.

  1. aws-cct --sort delta --sort-order desc

Output in CSV format

This will output in a CSV friendly format and you can utilize this to do analysis or for reporting.

  1. aws-cct --output csv

Diagnose where the largest cost increase is coming from

Between March & April 2022:

First, figure out which service has the largest cost

  1. aws-cct --start 2022-03-01 --end 2022-04-01 --sort delta --sort-order desc

Then, copy that full service name and dig into which specific line item within that service increased the most.

In this example, the EC2 costs are high and we want to see what specifically increased.

  1. aws-cct --start 2022-03-01 --end 2022-04-01 --sort delta --sort-order desc --service "Amazon Elastic Compute Cloud - Compute"

Local Development

Requires Go >= 1.15.3

Build with go build

You should see a local binary called aws-cct which you can use to interact with

Credits

AWS SDK for Go

Urfav CLI Lib

go-pretty for table output

License

MIT