• Stars
    star
    416
  • Rank 104,068 (Top 3 %)
  • Language
    TypeScript
  • Created almost 2 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CLI tool to perform cost analysis on your AWS account with Slack integration

aws-cost-cli

CLI tool to perform cost analysis on your AWS account with Slack integration

Installation

Install the package globally or alternatively you can also use npx

npm install -g aws-cost-cli

Usage

For the simple usage, just run the command without any options.

aws-cost

The output will be a the totals with breakdown by service. Optionally, you can pass the following options to modify the output:

$ aws-cost --help

  Usage: aws-cost [options]

  A CLI tool to perform cost analysis on your AWS account

  Options:
    -V, --version                  output the version number

    -k, --access-key [key]         AWS access key
    -s, --secret-key [key]         AWS secret key
    -r, --region [region]          AWS region (default: us-east-1)

    -p, --profile [profile]        AWS profile to use (default: "default")

    -j, --json                     Get the output as JSON
    -u, --summary                  Get only the summary without service breakdown
    -t, --text                     Get the output as plain text (no colors / tables)

    -S, --slack-token [token]      Slack token for the slack message
    -C, --slack-channel [channel]  Slack channel to post the message to

    -v, --version                  Get the version of the CLI
    -h, --help                     Get the help of the CLI

In order to use the CLI you can either pass the AWS credentials through the options i.e.:

aws-cost -k [key] -s [secret] -r [region]

or if you have configured the credentials using aws-cli, you can simply run the following command:

aws-cost

To configure the credentials using aws-cli, have a look at the aws-cli docs for more information.

Detailed Breakdown

The default usage is to get the cost breakdown by service

aws-cost

You will get the following output

Default Usage

Total Costs

You can also get the summary of the cost without the service breakdown

aws-cost --summary

You will get the following output

Summary Usage

Plain Text

You can also get the output as plain text

aws-cost --text

You will get the following output in response

Text Usage

JSON Output

You can also get the output as JSON

aws-cost --json
You will get the following output in response
{
  "account": "theroadmap",
  "totals": {
    "lastMonth": 0.38,
    "thisMonth": 11.86,
    "last7Days": 1.29,
    "yesterday": 0.22
  },
  "totalsByService": {
    "lastMonth": {
      "AmazonCloudWatch": 0,
      "Tax": 0,
      "AWS Key Management Service": 0,
      "AWS Service Catalog": 0,
      "Amazon Simple Email Service": 0.38,
      "Amazon Simple Notification Service": 0,
      "Amazon Simple Storage Service": 0.00001
    },
    "thisMonth": {
      "AmazonCloudWatch": 0,
      "Tax": 0,
      "AWS Key Management Service": 0,
      "AWS Service Catalog": 0,
      "Amazon Simple Email Service": 11.85,
      "Amazon Simple Notification Service": 0,
      "Amazon Simple Storage Service": 0
    },
    "last7Days": {
      "AmazonCloudWatch": 0,
      "Tax": 0,
      "AWS Key Management Service": 0,
      "AWS Service Catalog": 0,
      "Amazon Simple Email Service": 1.28,
      "Amazon Simple Notification Service": 0,
      "Amazon Simple Storage Service": 0
    },
    "yesterday": {
      "AmazonCloudWatch": 0,
      "Tax": 0,
      "AWS Key Management Service": 0,
      "AWS Service Catalog": 0,
      "Amazon Simple Email Service": 0.22,
      "Amazon Simple Notification Service": 0,
      "Amazon Simple Storage Service": 0
    }
  }
}

Slack Integration

You can also get the output as a slack message

aws-cost --slack-token [token] --slack-channel [channel]

You will get the message on slack with the breakdown:

Slack Usage

You can set up a GitHub workflow similar to this which can send the daily cost breakdown to Slack.

Note

Regarding the credentials, you need to have the following permissions in order to use the CLI:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "VisualEditor0",
      "Effect": "Allow",
      "Action": [
        "iam:ListAccountAliases",
        "ce:GetCostAndUsage"
      ],
      "Resource": "*"
    }
  ]
}

Also, please note that this tool uses AWS Cost Explorer under the hood which costs $0.01 per request.

License

MIT © Kamran Ahmed

More Repositories

1

developer-roadmap

Interactive roadmaps, guides and other educational content to help developers grow in their careers.
TypeScript
293,915
star
2

design-patterns-for-humans

An ultra-simplified explanation to design patterns
45,135
star
3

driver.js

A light-weight, no-dependency, vanilla JavaScript engine to drive user's focus across the page
TypeScript
22,682
star
4

git-standup

Recall what you did on the last working day. Psst! or be nosy and find what someone else in your team did ;-)
Shell
7,605
star
5

pennywise

Cross-platform application to open any website or media in a floating window
JavaScript
3,761
star
6

githunt

Hunt the most starred projects on any date on GitHub
JavaScript
2,863
star
7

roadmap.sh

Community driven roadmaps, articles and resources for developers
Nunjucks
2,196
star
8

jquery-toast-plugin

Highly customizable jquery plugin to show toast messages
JavaScript
1,511
star
9

brusher

Create beautiful webpage backgrounds
JavaScript
748
star
10

tab-switcher

Chrome Extension - Switch between the opened tabs in the blink of an eye
JavaScript
445
star
11

itomate

Automate your iTerm layouts and session setup
Python
335
star
12

datastructures-in-javascript

Illustrated Data Structures — Video Series
JavaScript
175
star
13

kamranahmedse.github.io

Blog created using github-pages-blog-action
HTML
166
star
14

awesome-minimal-sites

An opinionated collection of minimal yet beautiful websites.
158
star
15

local-ses

Trap and test AWS SES emails locally
TypeScript
157
star
16

pipeline-js

Pipeline pattern implementation with the support for sync and async stages
JavaScript
147
star
17

github-pages-blog-action

Create good looking blog from your markdown files in a GitHub repository
CSS
87
star
18

redux-persist-expire

Expiring transformer for redux-persist
JavaScript
78
star
19

css-tailor

✂ Automatically generate CSS from your HTML classes
JavaScript
68
star
20

stylos

Webpack plugin to automatically generate and inject CSS utilities to your application
JavaScript
67
star
21

git-first

Chrome Extension – Takes you to the first commit of a GitHub repository
JavaScript
66
star
22

express-api-problem

Express package to automatically turn your exceptions to the API Problem JSON response
TypeScript
65
star
23

laravel-faulty

Automatically turn your thrown exceptions to JSON response while conforming to API problem specification
PHP
64
star
24

smasher

Smash your directories to get JSON or Array representation and vice versa.
PHP
60
star
25

laravel-modular-boilerplate

A boilerplate to create modular application in laravel 5.1
PHP
59
star
26

copy-marker

Chrome extension — Create URLs with highlighted page selection
JavaScript
55
star
27

beetle

Abuse unicode to incite mayhem
Shell
53
star
28

db-playground

Easily create a sandbox environment for your database exploration.
Shell
50
star
29

jumper-bot

A game developed using HTML-5 canvas and Javascript
JavaScript
50
star
30

laravel-censor

A middleware for Laravel 5.* to easily redact or replace the words from the pages you want.
PHP
43
star
31

github-notable-comments

Chrome Extension – Navigate through the most reacted comments in github issues and PRs
JavaScript
40
star
32

gulp-css-tailor

✂ Gulp plugin to automatically generate CSS from your HTML classes
JavaScript
39
star
33

github-diffs

Easier code reviews by collapse/expand diffs in pull requests
JavaScript
35
star
34

laraformer

Laravel 5.* package to easily introduce a transformation layer for your data
PHP
32
star
35

brainza-fps-unity3d-game

First person shooter 3d game.
ASP
31
star
36

makers.ae

Community of makers in UAE
TypeScript
31
star
37

node-basic-auth-example

Sample implementation of Basic Authentication in Node.js
JavaScript
25
star
38

github-actions-youtube

Codebase for my youtube video on GitHub actions
HTML
25
star
39

php-shorthand

Calculate unique shorthands for a given set of strings
PHP
25
star
40

node-session-auth-example

Sample implementation of Session Authentication in Node.js
JavaScript
23
star
41

promises-examples

Codebase accompanying my YouTube video: All about Asynchronous JavaScript
23
star
42

mongo-playground

Single command to setup MongoDB playground with different datasets
Shell
22
star
43

tweet-counter

Chrome Extension - Bring back the character counters in tweet boxes
JavaScript
20
star
44

mongodumper

Docker image to back up MongoDB database and upload to S3
Shell
18
star
45

slack-msg

Dead simple CLI tool to send messages to Slack
JavaScript
18
star
46

gcuf-news-caster

Google Chrome Extension that shows the latest news from GCUF Website
JavaScript
17
star
47

mondex

CLI tool to create and manage MongoDB indexes using code
TypeScript
16
star
48

walkers

A console based fan fiction RPG for The Walking Dead TV Series
PHP
14
star
49

ng-atlas

An Angular JS application that lets you tour around the globe ..free of cost ;-)
JavaScript
13
star
50

markdown-it-class

Plugin for markdown-it to allow adding classes to HTML tags.
JavaScript
10
star
51

egghead-mongo-aggregation

Codebase for my "Aggregation in MongoDB" videos on Egghead
JavaScript
10
star
52

yaml-sample

JavaScript
8
star
53

sendy

Dockerized Sendy application with one-click deployment setup for Railway.
Shell
7
star
54

kamranahmedse

7
star
55

mulk

Gets the country details by country name, ITU or ISO codes
JavaScript
4
star
56

astro-view-transitions-bug

JavaScript
3
star
57

github-user-activity

JavaScript
3
star