{"id":16644850,"url":"https://github.com/toyama0919/awscost","last_synced_at":"2025-09-01T07:36:37.719Z","repository":{"id":52355086,"uuid":"225794709","full_name":"toyama0919/awscost","owner":"toyama0919","description":"table console view cost of aws.","archived":false,"fork":false,"pushed_at":"2024-12-30T12:32:53.000Z","size":113,"stargazers_count":13,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-09T08:14:45.961Z","etag":null,"topics":["aws","cost","costexplorer","pypi","python","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","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/toyama0919.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}},"created_at":"2019-12-04T06:22:36.000Z","updated_at":"2025-03-28T15:23:42.000Z","dependencies_parsed_at":"2024-07-07T08:27:14.561Z","dependency_job_id":null,"html_url":"https://github.com/toyama0919/awscost","commit_stats":{"total_commits":104,"total_committers":2,"mean_commits":52.0,"dds":0.04807692307692313,"last_synced_commit":"ea9e4d01d0d2642fc5ed72a7454978262a322d6c"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/toyama0919/awscost","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toyama0919%2Fawscost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toyama0919%2Fawscost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toyama0919%2Fawscost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toyama0919%2Fawscost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toyama0919","download_url":"https://codeload.github.com/toyama0919/awscost/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toyama0919%2Fawscost/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265731077,"owners_count":23818868,"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","cost","costexplorer","pypi","python","python3"],"created_at":"2024-10-12T08:12:29.274Z","updated_at":"2025-07-30T07:33:48.942Z","avatar_url":"https://github.com/toyama0919.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# awscost\n\n[![PyPI version](https://badge.fury.io/py/awscost.svg)](https://badge.fury.io/py/awscost)\n[![Build Status](https://github.com/toyama0919/awscost/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/toyama0919/awscost/actions/workflows/ci.yml)\n\nCommand Line utility for Provides aws cost very easy to see.\n\nSupports python 3.8 or later.\n\n## Install\n\n```bash\n$ pip install awscost\n```\n\n## Examples\n\n### show cost\n\nshow cost latest 5 months.\n\n```bash\n$ awscost\nkey                                       2019-07    2019-08    2019-09    2019-10    2019-11    2019-12\n--------------------------------------  ---------  ---------  ---------  ---------  ---------  ---------\nTotal                                      348.34      97.4       98.46     106.47      67.25       7.84\nEC2 - Other                                 34.28      34.28      33.2       34.28      33.63       3.01\nAmazon Elastic Compute Cloud - Compute      17.11      17.11      16.56      17.11      17.13       1.47\nAWS Cost Explorer                                                                        0.56       1.44\nTax                                         25.8        7.22       7.27       9.72       6.12       0.69\nAWS CloudTrail                               3.29       3.21       4.15       5.57       4.44       0.61\nAWS Key Management Service                   0          0          2.8        4          4          0.35\nAmazonCloudWatch                             1.5        0.01       0          0          0.88       0.11\nAmazon Route 53                              0.1        0.1        0.1        0.1        0.1        0.1\nAmazon Simple Storage Service                0.25       0.24       0.27       0.45       0.4        0.05\nAWS Lambda                                   0          0          0          0          0          0\nAmazon DynamoDB                              0          0          0          0          0\nAmazon Elastic File System                   0          0          0          0          0          0\nAmazon SageMaker                           266         35.22      34.11      35.22       0\nAmazon Simple Notification Service           0          0                                0\nAmazon Polly                                                                  0\nAmazon Simple Queue Service                                                              0\n```\n\nshow cost latest 3 days, group by SERVICE and operation.\n\n```bash\n$ awscost -g DAILY -p 3 -d SERVICE -d OPERATION\nkey                                                             2019-12-01    2019-12-02    2019-12-03\n------------------------------------------------------------  ------------  ------------  ------------\nTotal                                                                 2.87          2.1           2.87\nGetCostAndUsage,AWS Cost Explorer                                                   0.02          1.42\nNatGateway,EC2 - Other                                                1.08          1.08          0.77\nRunInstances,Amazon Elastic Compute Cloud - Compute                   0.55          0.55          0.37\nNone,AWS CloudTrail                                                   0.22          0.22          0.17\nUnknown,AWS Key Management Service                                    0.13          0.13          0.09\nUnknown,AmazonCloudWatch                                              0.04          0.04          0.03\nCreateVolume-Gp2,EC2 - Other                                          0.03          0.03          0.01\nPutObject,Amazon Simple Storage Service                               0.02          0.02          0.01\nNoOperation,Tax                                                       0.25\n...\n```\n\n### support dimensions\n\n* AZ\n* INSTANCE_TYPE\n* LINKED_ACCOUNT\n* OPERATION\n* PURCHASE_TYPE\n* SERVICE\n* USAGE_TYPE\n* PLATFORM\n* TENANCY\n* RECORD_TYPE\n* LEGAL_ENTITY_NAME\n* DEPLOYMENT_OPTION\n* DATABASE_ENGINE\n* CACHE_ENGINE\n* INSTANCE_TYPE_FAMILY\n* REGION\n* BILLING_ENTITY\n* RESERVATION_ID\n* SAVINGS_PLANS_TYPE\n* SAVINGS_PLAN_ARN\n* OPERATING_SYSTEM\n\nsee. https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_GetDimensionValues.html\n\n### support filter\n\n```bash\nawscost --filter '{\n  \"Not\": {\n    \"Dimensions\": {\n      \"Key\": \"RECORD_TYPE\",\n      \"Values\": [\"Credit\", \"Refund\", \"Upfront\"]\n    }\n  }\n}'\n```\n\n## config file($HOME/.awscost)\n\n```yaml:$HOME/.awscost\ndefault:\n  metrics: AmortizedCost\n  filter:\n    Dimensions:\n      Key: RECORD_TYPE\n      Values:\n        - Usage\n        - Tax\n\ndiscount:\n  filter:\n    Dimensions:\n      Key: RECORD_TYPE\n      Values:\n        - Credit\n        - Refund\n        - Upfront\n\nec2:\n  filter:\n    Dimensions:\n      Key: SERVICE\n      Values:\n        - \"EC2 - Other\"\n        - \"Amazon Elastic Compute Cloud - Compute\"\n```\n\nYou can exec command as below.\n\n```bash\n$ awscost --profile default\n$ awscost --profile discount\n$ awscost --profile ec2\n```\n\n#### group by tag\n\nYou can set up a group by tag.\n\nCurrently, this cannot be achieved using only the command line.\n\nWrite the following in yaml in $HOME/.awscost\n\nThe following is an example of grouping by the tag \"Product\"\n\n```yaml:$HOME/.awscost\ntag:\n  tags:\n    - Product\n  dimensions: []\n```\n\nYou can exec command as below.\n\n```bash\n$ awscost --profile tag\n```\n\n## Various format(-t option)\n\nexample, use -t tsv.\n\ndefault is simple.\n\n```bash\n$ awscost -d SERVICE -d OPERATION -t tsv\nkey                                                             01-24   01-25   01-26   01-27   01-28   01-29   01-30   01-31   02-01   02-02\nTotal                                                            2       2       2       2       2.02    2.01    2.01    2.01    2.5     1.67\nEC2 - Other,NatGateway                                           1.08    1.08    1.08    1.08    1.08    1.08    1.08    1.08    1.08    0.9\nAmazon Elastic Compute Cloud - Compute,RunInstances              0.55    0.55    0.55    0.55    0.55    0.55    0.55    0.55    0.55    0.46\n...\n```\n\n### support format\n- simple(default)\n- plain\n- github\n- grid\n- fancy_grid\n- pipe\n- orgtbl\n- jira\n- presto\n- psql\n- rst\n- mediawiki\n- moinmoin\n- youtrack\n- html\n- latex\n- latex_raw\n- latex_booktabs\n- textile\n- tsv\n\n## Settings\n\naws auth support following.\n\n* environment variables\n* profile(use --aws-profile option.)\n* instance profile\n\n\n\n## Python API\n\n```py\nfrom awscost.cost_explorer import CostExplorer\nfrom dateutil.relativedelta import relativedelta\nfrom datetime import datetime\n\nstart = (datetime.today() - relativedelta(months=3)).strftime(\"%Y-%m-01\")\nend = datetime.today().strftime(\"%Y-%m-01\")\n\ncost_explorer = CostExplorer(\n    granularity=\"MONTHLY\",\n    start=start,\n    end=end,\n    dimensions=[\"SERVICE\"],\n    metrics=\"UnblendedCost\",\n    threshold=1.0,\n).get_cost_and_usage_total_and_group_by()\n\n# return dict data.\ncost_explorer # =\u003e\n# {   'AWS CloudTrail': {'2019-11': 4.44, '2019-12': 6.17, '2020-01': 4.38},\n#     'AWS Lambda': {'2019-11': 0.0, '2019-12': 0.0, '2020-01': 0.0},\n# ...\n#     'Total': {'2019-11': 67.15, '2019-12': 72.22, '2020-01': 68.11}}\n\n```\n\n### matplotlib\n\n```py\n...\n\nimport matplotlib.pyplot as plt\n\nplt.figure(figsize=(25, 15), dpi=100)\nplt.xlabel('month', fontsize=16)\nplt.ylabel('$', fontsize=16)\nplt.grid(True)\nfor i, (service_name, v) in enumerate(cost_explorer.items()):\n    left = list(v.keys())\n    height = list(v.values())\n    plt.plot(left, height, linewidth=2, label=service_name, marker='o')\nplt.legend(loc='best', fontsize=15, numpoints=5)\n\nplt.show()\n\n```\n\n## iam policy\n\n```json\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Sid\": \"xxxxxxxxx\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"ce:GetCostAndUsage\"\n            ],\n            \"Resource\": \"*\"\n        }\n    ]\n}\n```\n\n## CI\n\n### install test package\n\n```bash\n$ ./scripts/ci.sh install-test\n```\n\n### test\n\n```bash\n$ ./scripts/ci.sh run-test\n```\n\nflake8 and black and pytest.\n\n### release pypi\n\n```bash\n$ ./scripts/ci.sh release\n```\n\ngit tag and pypi release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoyama0919%2Fawscost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoyama0919%2Fawscost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoyama0919%2Fawscost/lists"}