{"id":13618362,"url":"https://github.com/kamranahmedse/aws-cost-cli","last_synced_at":"2025-05-16T15:03:14.809Z","repository":{"id":65411973,"uuid":"591551573","full_name":"kamranahmedse/aws-cost-cli","owner":"kamranahmedse","description":"CLI tool to perform cost analysis on your AWS account with Slack integration","archived":false,"fork":false,"pushed_at":"2025-01-13T03:15:13.000Z","size":31240,"stargazers_count":438,"open_issues_count":9,"forks_count":30,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-12T12:54:04.696Z","etag":null,"topics":["aws","aws-cost","aws-cost-and-usage-report","aws-cost-explorer","aws-cost-saving","github-action"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kamranahmedse.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-01-21T04:00:37.000Z","updated_at":"2025-03-23T08:34:46.000Z","dependencies_parsed_at":"2024-08-01T20:47:12.496Z","dependency_job_id":"f295d8aa-e72e-4d99-85cd-615e78191d3e","html_url":"https://github.com/kamranahmedse/aws-cost-cli","commit_stats":{"total_commits":52,"total_committers":2,"mean_commits":26.0,"dds":"0.019230769230769273","last_synced_commit":"49056014aa6adddf4778cd3623a1bae6abb38a9c"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamranahmedse%2Faws-cost-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamranahmedse%2Faws-cost-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamranahmedse%2Faws-cost-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kamranahmedse%2Faws-cost-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kamranahmedse","download_url":"https://codeload.github.com/kamranahmedse/aws-cost-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254544159,"owners_count":22088808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-cost","aws-cost-and-usage-report","aws-cost-explorer","aws-cost-saving","github-action"],"created_at":"2024-08-01T20:01:59.557Z","updated_at":"2025-05-16T15:03:14.758Z","avatar_url":"https://github.com/kamranahmedse.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"## aws-cost-cli\n\u003e CLI tool to perform cost analysis on your AWS account with Slack integration\n\n![](.github/images/aws-cost.gif)\n\n## Installation\n\nInstall the package globally or alternatively you can also use `npx`\n\n```bash\nnpm install -g aws-cost-cli\n```\n\n## Usage\n\nFor the simple usage, just run the command without any options. \n\n```\naws-cost\n```\n\nThe output will be a the totals with breakdown by service. Optionally, you can pass the following options to modify the output:\n\n```bash\n$ aws-cost --help\n\n  Usage: aws-cost [options]\n\n  A CLI tool to perform cost analysis on your AWS account\n\n  Options:\n    -V, --version                  output the version number\n\n    -k, --access-key [key]         AWS access key\n    -s, --secret-key [key]         AWS secret key\n    -r, --region [region]          AWS region (default: us-east-1)\n\n    -p, --profile [profile]        AWS profile to use (default: \"default\")\n\n    -j, --json                     Get the output as JSON\n    -u, --summary                  Get only the summary without service breakdown\n    -t, --text                     Get the output as plain text (no colors / tables)\n\n    -S, --slack-token [token]      Slack token for the slack message\n    -C, --slack-channel [channel]  Slack channel to post the message to\n\n    -v, --version                  Get the version of the CLI\n    -h, --help                     Get the help of the CLI\n```\n\nIn order to use the CLI you can either pass the AWS credentials through the options i.e.:\n\n```bash\naws-cost -k [key] -s [secret] -r [region]\n```\n\nor if you have configured the credentials using [aws-cli](https://github.com/aws/aws-cli), you can simply run the following command:\n\n```bash\naws-cost\n```\n\nTo configure the credentials using aws-cli, have a look at the [aws-cli docs](https://github.com/aws/aws-cli#configuration) for more information.\n\n### Docker\n\nYou can build this Dockerfile using the docker build command and then run a container from the built image. For example:\n\n```\ndocker build -t aws-cost-cli .\ndocker run aws-cost-cli\n```\n\n## Detailed Breakdown\n\u003e The default usage is to get the cost breakdown by service\n\n```bash\naws-cost\n```\nYou will get the following output\n\n![Default Usage](./.github/images/default-demo.gif)\n\n## Total Costs\n\u003e You can also get the summary of the cost without the service breakdown\n\n```bash\naws-cost --summary\n```\nYou will get the following output\n\n![Summary Usage](./.github/images/summary-demo.gif)\n\n## Plain Text\n\u003e You can also get the output as plain text\n\n```bash\naws-cost --text\n```\nYou will get the following output in response\n\n![Text Usage](./.github/images/text-usage.png)\n\n## JSON Output\n\u003e You can also get the output as JSON\n\n```bash\naws-cost --json\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eYou will get the following output in response\u003c/summary\u003e\n\n```json\n{\n  \"account\": \"theroadmap\",\n  \"totals\": {\n    \"lastMonth\": 0.38,\n    \"thisMonth\": 11.86,\n    \"last7Days\": 1.29,\n    \"yesterday\": 0.22\n  },\n  \"totalsByService\": {\n    \"lastMonth\": {\n      \"AmazonCloudWatch\": 0,\n      \"Tax\": 0,\n      \"AWS Key Management Service\": 0,\n      \"AWS Service Catalog\": 0,\n      \"Amazon Simple Email Service\": 0.38,\n      \"Amazon Simple Notification Service\": 0,\n      \"Amazon Simple Storage Service\": 0.00001\n    },\n    \"thisMonth\": {\n      \"AmazonCloudWatch\": 0,\n      \"Tax\": 0,\n      \"AWS Key Management Service\": 0,\n      \"AWS Service Catalog\": 0,\n      \"Amazon Simple Email Service\": 11.85,\n      \"Amazon Simple Notification Service\": 0,\n      \"Amazon Simple Storage Service\": 0\n    },\n    \"last7Days\": {\n      \"AmazonCloudWatch\": 0,\n      \"Tax\": 0,\n      \"AWS Key Management Service\": 0,\n      \"AWS Service Catalog\": 0,\n      \"Amazon Simple Email Service\": 1.28,\n      \"Amazon Simple Notification Service\": 0,\n      \"Amazon Simple Storage Service\": 0\n    },\n    \"yesterday\": {\n      \"AmazonCloudWatch\": 0,\n      \"Tax\": 0,\n      \"AWS Key Management Service\": 0,\n      \"AWS Service Catalog\": 0,\n      \"Amazon Simple Email Service\": 0.22,\n      \"Amazon Simple Notification Service\": 0,\n      \"Amazon Simple Storage Service\": 0\n    }\n  }\n}\n```\n\u003c/details\u003e\n\n## Slack Integration\n\n\u003e You can also get the output as a slack message\n\nYou will need to create [a slack app](https://api.slack.com/apps?new_app=1), visit the **OAuth \u0026 Permissions** tab, and add the `chat:write` and `chat:write.public` scopes. Then create an OAuth token from the \"OAuth Tokens\" section and pass it to the CLI.\n\n\u003e **Note:** The `--slack-channel` is the [channel id](https://stackoverflow.com/questions/40940327/what-is-the-simplest-way-to-find-a-slack-team-id-and-a-channel-id#answer-44883343), not the name.\n\n```bash\naws-cost --slack-token [token] --slack-channel [channel]\n```\n\nYou will get the message on slack with the breakdown:\n\n![Slack Usage](./.github/images/slack-usage.png)\n\nYou can set up a GitHub [workflow similar to this](https://github.com/kamranahmedse/developer-roadmap/blob/c1a53cf3cc5c9b77634673754c8a5af4e83466d6/.github/workflows/aws-costs.yml#L1) which can send the daily cost breakdown to Slack.\n\n## Note\n\nRegarding the credentials, you need to have the following permissions in order to use the CLI:\n\n```json\n{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Sid\": \"VisualEditor0\",\n      \"Effect\": \"Allow\",\n      \"Action\": [\n        \"iam:ListAccountAliases\",\n        \"ce:GetCostAndUsage\"\n      ],\n      \"Resource\": \"*\"\n    }\n  ]\n}\n```\n\nAlso, please note that this tool uses AWS Cost Explorer under the hood which [costs $0.01 per request](https://aws.amazon.com/aws-cost-management/aws-cost-explorer/pricing/).\n\n## License\nMIT \u0026copy; [Kamran Ahmed](https://twitter.com/kamranahmedse)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamranahmedse%2Faws-cost-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkamranahmedse%2Faws-cost-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkamranahmedse%2Faws-cost-cli/lists"}