Skip to content

Instantly share code, notes, and snippets.

@dbt4u
Created September 24, 2019 16:54
Show Gist options
  • Save dbt4u/700d3a11fb514ca69bfe743602bf4375 to your computer and use it in GitHub Desktop.
Save dbt4u/700d3a11fb514ca69bfe743602bf4375 to your computer and use it in GitHub Desktop.
Get the AWS cost of this month per Service
aws ce get-cost-and-usage --time-period Start=$(date "+%Y-%m-01"),End=$(date --date="$(date +'%Y-%m-01') + 1 month - 1 second" -I) --granularity MONTHLY --metrics USAGE_QUANTITY BLENDED_COST --group-by Type=DIMENSION,Key=SERVICE | jq '[ .ResultsByTime[].Groups[] | select(.Metrics.BlendedCost.Amount > "0") | { (.Keys[0]): .Metrics.BlendedCost } ] | sort_by(.Amount) | add'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment