aws-waste-hunter 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. aws_waste_hunter-0.1.0/.dockerignore +7 -0
  2. aws_waste_hunter-0.1.0/.github/dependabot.yml +10 -0
  3. aws_waste_hunter-0.1.0/.github/workflows/ci.yml +60 -0
  4. aws_waste_hunter-0.1.0/.github/workflows/codeql.yml +28 -0
  5. aws_waste_hunter-0.1.0/.github/workflows/release.yml +24 -0
  6. aws_waste_hunter-0.1.0/.gitignore +17 -0
  7. aws_waste_hunter-0.1.0/Dockerfile +13 -0
  8. aws_waste_hunter-0.1.0/LICENSE +202 -0
  9. aws_waste_hunter-0.1.0/PKG-INFO +156 -0
  10. aws_waste_hunter-0.1.0/README.md +137 -0
  11. aws_waste_hunter-0.1.0/SECURITY.md +18 -0
  12. aws_waste_hunter-0.1.0/THREAT_MODEL.md +33 -0
  13. aws_waste_hunter-0.1.0/docs/launch-post.md +21 -0
  14. aws_waste_hunter-0.1.0/docs/sample-report.md +21 -0
  15. aws_waste_hunter-0.1.0/iam/policy.json +32 -0
  16. aws_waste_hunter-0.1.0/pyproject.toml +41 -0
  17. aws_waste_hunter-0.1.0/requirements.lock +38 -0
  18. aws_waste_hunter-0.1.0/scripts/make_sample_report.py +110 -0
  19. aws_waste_hunter-0.1.0/src/aws_waste_hunter/__init__.py +3 -0
  20. aws_waste_hunter-0.1.0/src/aws_waste_hunter/accounts.py +65 -0
  21. aws_waste_hunter-0.1.0/src/aws_waste_hunter/checks/__init__.py +22 -0
  22. aws_waste_hunter-0.1.0/src/aws_waste_hunter/checks/base.py +23 -0
  23. aws_waste_hunter-0.1.0/src/aws_waste_hunter/checks/ebs_gp2.py +53 -0
  24. aws_waste_hunter-0.1.0/src/aws_waste_hunter/checks/ebs_unattached.py +44 -0
  25. aws_waste_hunter-0.1.0/src/aws_waste_hunter/checks/eip_unassociated.py +46 -0
  26. aws_waste_hunter-0.1.0/src/aws_waste_hunter/checks/lb_idle.py +82 -0
  27. aws_waste_hunter-0.1.0/src/aws_waste_hunter/checks/log_retention.py +48 -0
  28. aws_waste_hunter-0.1.0/src/aws_waste_hunter/checks/nat_idle.py +72 -0
  29. aws_waste_hunter-0.1.0/src/aws_waste_hunter/cli.py +141 -0
  30. aws_waste_hunter-0.1.0/src/aws_waste_hunter/metrics.py +109 -0
  31. aws_waste_hunter-0.1.0/src/aws_waste_hunter/models.py +75 -0
  32. aws_waste_hunter-0.1.0/src/aws_waste_hunter/pricing.py +222 -0
  33. aws_waste_hunter-0.1.0/src/aws_waste_hunter/readonly.py +70 -0
  34. aws_waste_hunter-0.1.0/src/aws_waste_hunter/regions.py +29 -0
  35. aws_waste_hunter-0.1.0/src/aws_waste_hunter/report.py +78 -0
  36. aws_waste_hunter-0.1.0/src/aws_waste_hunter/runner.py +85 -0
  37. aws_waste_hunter-0.1.0/terraform/scanner-role/.terraform.lock.hcl +26 -0
  38. aws_waste_hunter-0.1.0/terraform/scanner-role/README.md +22 -0
  39. aws_waste_hunter-0.1.0/terraform/scanner-role/main.tf +45 -0
  40. aws_waste_hunter-0.1.0/terraform/scanner-role/outputs.tf +4 -0
  41. aws_waste_hunter-0.1.0/terraform/scanner-role/variables.tf +30 -0
  42. aws_waste_hunter-0.1.0/tests/conftest.py +13 -0
  43. aws_waste_hunter-0.1.0/tests/test_accounts_parallel.py +188 -0
  44. aws_waste_hunter-0.1.0/tests/test_checks.py +95 -0
  45. aws_waste_hunter-0.1.0/tests/test_metric_checks.py +123 -0
  46. aws_waste_hunter-0.1.0/tests/test_no_network_egress.py +38 -0
  47. aws_waste_hunter-0.1.0/tests/test_pricing.py +162 -0
  48. aws_waste_hunter-0.1.0/tests/test_readonly.py +130 -0
  49. aws_waste_hunter-0.1.0/tests/test_runner_report_cli.py +109 -0
@@ -0,0 +1,7 @@
1
+ .git
2
+ .venv
3
+ .terraform
4
+ tests
5
+ docs
6
+ *.md
7
+ !README.md
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: pip
4
+ directory: /
5
+ schedule:
6
+ interval: weekly
7
+ - package-ecosystem: github-actions
8
+ directory: /
9
+ schedule:
10
+ interval: weekly
@@ -0,0 +1,60 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ pull_request:
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ python: ["3.10", "3.12", "3.13"]
16
+ steps:
17
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
18
+ with:
19
+ persist-credentials: false
20
+ - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
21
+ with:
22
+ python-version: ${{ matrix.python }}
23
+ - run: pip install -e ".[dev]"
24
+ - run: ruff check .
25
+ - run: mypy src
26
+ - run: pytest --cov=aws_waste_hunter
27
+ env:
28
+ # Tests use moto only; make sure no real credentials can ever be picked up.
29
+ AWS_ACCESS_KEY_ID: testing
30
+ AWS_SECRET_ACCESS_KEY: testing
31
+ AWS_DEFAULT_REGION: us-east-1
32
+ - name: Audit runtime dependencies
33
+ run: pip-audit .
34
+ - name: Install from the hash-pinned lockfile (what end users get)
35
+ run: pip install --require-hashes --no-deps -r requirements.lock
36
+
37
+ secrets:
38
+ runs-on: ubuntu-latest
39
+ permissions:
40
+ contents: read
41
+ pull-requests: read # the action lists the PR's commits to scan
42
+ steps:
43
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
44
+ with:
45
+ fetch-depth: 0
46
+ persist-credentials: false
47
+ - uses: gitleaks/gitleaks-action@e0c47f4f8be36e29cdc102c57e68cb5cbf0e8d1e # v3.0.0
48
+ env:
49
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50
+
51
+ docker:
52
+ runs-on: ubuntu-latest
53
+ steps:
54
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
55
+ with:
56
+ persist-credentials: false
57
+ - name: Build image and smoke-test it (no push)
58
+ run: |
59
+ docker build -t aws-waste-hunter:ci .
60
+ docker run --rm aws-waste-hunter:ci --version
@@ -0,0 +1,28 @@
1
+ name: CodeQL
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ pull_request:
6
+ schedule:
7
+ - cron: "17 4 * * 1"
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ analyze:
14
+ # Code scanning needs GitHub Advanced Security on private repos; runs automatically once public.
15
+ if: github.event.repository.private == false
16
+ runs-on: ubuntu-latest
17
+ permissions:
18
+ security-events: write
19
+ contents: read
20
+ actions: read
21
+ steps:
22
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
23
+ with:
24
+ persist-credentials: false
25
+ - uses: github/codeql-action/init@9418214df1f2c4b8128c770156c409013b07d6b9 # v3
26
+ with:
27
+ languages: python
28
+ - uses: github/codeql-action/analyze@9418214df1f2c4b8128c770156c409013b07d6b9 # v3
@@ -0,0 +1,24 @@
1
+ name: Release
2
+ on:
3
+ push:
4
+ tags: ["v*"]
5
+
6
+ permissions:
7
+ contents: read
8
+
9
+ jobs:
10
+ pypi:
11
+ runs-on: ubuntu-latest
12
+ environment: pypi # configure the PyPI trusted publisher for this repo + environment
13
+ permissions:
14
+ contents: read
15
+ id-token: write # OIDC trusted publishing: no PyPI token is stored anywhere
16
+ steps:
17
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
18
+ with:
19
+ persist-credentials: false
20
+ - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
21
+ with:
22
+ python-version: "3.13"
23
+ - run: python -m pip install build && python -m build
24
+ - uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
@@ -0,0 +1,17 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .pytest_cache/
7
+ .mypy_cache/
8
+ .ruff_cache/
9
+ .coverage
10
+ htmlcov/
11
+ reports/
12
+ .env
13
+ .DS_Store
14
+
15
+ # terraform
16
+ .terraform/
17
+ *.tfstate*
@@ -0,0 +1,13 @@
1
+ FROM python:3.13-slim
2
+
3
+ # Hash-pinned dependencies first, then the package itself without resolving anything.
4
+ WORKDIR /app
5
+ COPY requirements.lock ./
6
+ RUN pip install --no-cache-dir --require-hashes --no-deps -r requirements.lock
7
+ COPY pyproject.toml README.md LICENSE ./
8
+ COPY src ./src
9
+ RUN pip install --no-cache-dir --no-deps . && useradd --create-home scanner
10
+
11
+ USER scanner
12
+ # Credentials come from the environment or a mounted ~/.aws; nothing is baked into the image.
13
+ ENTRYPOINT ["aws-waste-hunter"]
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,156 @@
1
+ Metadata-Version: 2.5
2
+ Name: aws-waste-hunter
3
+ Version: 0.1.0
4
+ Summary: Read-only, auditable AWS waste scanner with dollar estimates.
5
+ Author-email: Helyx IT <support@helyxit.com>
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: boto3<2,>=1.34
10
+ Provides-Extra: dev
11
+ Requires-Dist: boto3-stubs[essential]>=1.34; extra == 'dev'
12
+ Requires-Dist: moto[ec2,ecr,elbv2,logs,s3]>=5; extra == 'dev'
13
+ Requires-Dist: mypy>=1.11; extra == 'dev'
14
+ Requires-Dist: pip-audit>=2.7; extra == 'dev'
15
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
16
+ Requires-Dist: pytest>=8; extra == 'dev'
17
+ Requires-Dist: ruff>=0.6; extra == 'dev'
18
+ Description-Content-Type: text/markdown
19
+
20
+ # aws-waste-hunter
21
+
22
+ Read-only, auditable AWS waste scanner that tells you **how many dollars** you can save.
23
+ Built by [Helyx IT](https://helyxit.com).
24
+
25
+ > **Status:** alpha (0.1.0). Parallel multi-region and cross-account scans, live pricing, six checks including metric-based idle detection with a hard cost cap.
26
+
27
+ ## Why this one
28
+ - **It can't change your account.** Every AWS call is `Describe*`, `List*` or `Get*`, enforced
29
+ three ways: in code, in tests, and in the IAM policy you attach.
30
+ - **It runs on your machine.** No SaaS, no agent, no telemetry. Nothing leaves your account.
31
+ - **You can read all of it.** Small codebase, minimal dependencies, published least-privilege
32
+ IAM policy.
33
+ - **It speaks dollars.** Every finding has a monthly cost and a savings estimate, priced from
34
+ the live AWS Price List API.
35
+
36
+ ## Install
37
+ ```bash
38
+ pipx install aws-waste-hunter # after the first PyPI release
39
+ docker build -t aws-waste-hunter . && docker run --rm -v ~/.aws:/home/scanner/.aws:ro \
40
+ aws-waste-hunter scan --region us-east-1 --profile my-sso-profile
41
+ pip install --require-hashes --no-deps -r requirements.lock && pip install --no-deps . # from source, hash-pinned
42
+ ```
43
+ See a [sample report](docs/sample-report.md) (fictional data).
44
+
45
+ ## Usage
46
+ ```bash
47
+ pip install -e .
48
+
49
+ aws-waste-hunter scan --region us-east-1 --profile my-sso-profile
50
+ aws-waste-hunter scan --regions us-east-1,eu-west-1 --format json --output report.json
51
+ aws-waste-hunter scan --all-regions
52
+ aws-waste-hunter scan --region us-east-1 --pricing offline # no Price List calls
53
+ aws-waste-hunter scan --region us-east-1 --max-metrics 50 # tighter CloudWatch cost cap
54
+ aws-waste-hunter scan --all-regions --concurrency 12 # parallel (default 8, max 16)
55
+
56
+ # Other accounts: assume a read-only role in each (repeat --role-arn for more accounts)
57
+ aws-waste-hunter scan --all-regions \
58
+ --role-arn arn:aws:iam::222222222222:role/aws-waste-hunter-scanner \
59
+ --external-id "$WASTE_HUNTER_EXTERNAL_ID"
60
+ ```
61
+ Create the cross-account role with the Terraform module in
62
+ [`terraform/scanner-role`](terraform/scanner-role): trust is limited to the principals you list
63
+ and requires an ExternalId; permissions are exactly [`iam/policy.json`](iam/policy.json).
64
+ Attach [`iam/policy.json`](iam/policy.json) to the role you scan with. Reports are written
65
+ with `0600` permissions because they describe your account.
66
+
67
+ ## Checks
68
+ | ID | Finds |
69
+ |---|---|
70
+ | `ebs-unattached` | EBS volumes not attached to anything |
71
+ | `ebs-gp2-to-gp3` | in-use gp2 volumes that could be gp3 (~20% cheaper) |
72
+ | `eip-unassociated` | Elastic IPs allocated but not associated |
73
+ | `logs-no-retention` | CloudWatch log groups that never expire |
74
+ | `nat-idle` | NAT gateways (older than 7 days) that moved 0 bytes in the last 7 days |
75
+ | `lb-idle` | Application/Network load balancers (older than 7 days) with no traffic in 7 days |
76
+
77
+ `nat-idle` and `lb-idle` read CloudWatch (`GetMetricData`, billed ~$0.01 per 1,000 metrics).
78
+ Every query is charged against a budget first: `--max-metrics` (default 200 per account and
79
+ region, about $0.002). If the cap is reached the check stops, keeps what it found, and reports
80
+ the error. Their dollar figures use us-east-1 list prices, so treat them as estimates.
81
+
82
+ A check that fails (for example a missing permission) is listed in the report and the exit
83
+ code is 1. It is never silently skipped.
84
+
85
+ ## Pricing
86
+ Prices come from the AWS Price List API per region, are cached for 24 hours, and fall back to
87
+ an offline us-east-1 list-price table if the lookup fails. Every report states which source
88
+ was used. Live and cached values must be positive and within a sane band of the reference, so
89
+ a bad parse or a tampered cache cannot inflate your numbers. Amounts are estimates, not quotes.
90
+
91
+ ## Security model
92
+ - Read-only guard on every call, plus a CI test that fails on any other operation.
93
+ - Least-privilege IAM policy with no wildcards; every check's required actions are
94
+ test-verified against it.
95
+ - AWS clients can only be created through one guarded helper (bounded timeouts, bounded
96
+ retries, validated region); a test fails if any other code creates a raw client.
97
+ - Region names are validated before they reach endpoints or file paths.
98
+ - Resource names and tags are treated as untrusted input when rendering reports.
99
+ - Cross-account scans use short-lived (1h) assumed-role credentials that stay in memory; the
100
+ only non-read operation allowed through the guard is the exact `sts:AssumeRole`.
101
+ - Standard AWS credential chain / SSO only. Credentials are never stored, logged or sent.
102
+ - GitHub Actions are pinned to commit SHAs.
103
+
104
+ See [SECURITY.md](SECURITY.md) to report a vulnerability.
105
+
106
+ ---
107
+
108
+ # Pro (planned)
109
+
110
+ The open-source scanner finds the mechanical waste. **Pro** is where it becomes a savings
111
+ program. These features are on the roadmap and are **not available yet**; the order below is
112
+ the rough build order.
113
+
114
+ ### Find more, across everything
115
+ - **Org-wide scans.** Cross-account scanning works today with `--role-arn`; Pro adds automatic
116
+ discovery of every account in your AWS Organization.
117
+ - **More metric-based idle detection.** Idle EC2 and RDS (NAT gateways and load balancers
118
+ are already in the open-source scanner). The waste that metadata alone can't show, with a hard cost cap
119
+ so the scan itself never surprises you.
120
+ - **EKS right-sizing.** Requests vs real usage from Datadog or Prometheus, plus the
121
+ autoscaler blockers that keep nodes alive. The same playbook behind a 70%+ node reduction.
122
+ - **Commitment review.** Savings Plans and Reserved Instance coverage, usually the single
123
+ biggest lever.
124
+
125
+ ### Fix it safely
126
+ - **Fix-as-code merge requests.** Generates the Terraform or CLI change as a GitLab or
127
+ GitHub MR for a human to review. It never applies anything itself.
128
+ - **Terraform cost guard.** Estimates the monthly cost of every `terraform plan` and flags
129
+ expensive patterns before they merge.
130
+ - **Suppressions with expiry.** Accept a finding per resource or tag, with an owner and a
131
+ review date, kept as policy-as-code in your repo.
132
+
133
+ ### Prove the savings
134
+ - **Trend history and scheduled scans.** Weekly digests to Slack or email and a running total
135
+ of dollars saved, so the program has numbers behind it.
136
+ - **AI prioritization in your own account.** Ranks findings by effort versus payoff using
137
+ Bedrock (or a local model). The AI only summarizes: it never detects and never acts, and
138
+ nothing leaves your account.
139
+ - **Export anywhere.** SARIF, CSV and Jira.
140
+
141
+ ### Don't want to run it yourself?
142
+ Helyx does manual, expert-led AWS reviews with a guaranteed 15% savings, and goes where
143
+ automation can't: architecture, data-transfer design and commitment strategy.
144
+ [Book a call](https://helyxit.com).
145
+
146
+ ## Develop
147
+ ```bash
148
+ python3.13 -m venv ~/.venvs/aws-waste-hunter && source ~/.venvs/aws-waste-hunter/bin/activate
149
+ pip install -e ".[dev]"
150
+ ruff check . && mypy src && pytest
151
+ ```
152
+ Tests use [moto](https://github.com/getmoto/moto) and canned Price List responses; no AWS
153
+ account or credentials needed.
154
+
155
+ ## License
156
+ Apache-2.0
@@ -0,0 +1,137 @@
1
+ # aws-waste-hunter
2
+
3
+ Read-only, auditable AWS waste scanner that tells you **how many dollars** you can save.
4
+ Built by [Helyx IT](https://helyxit.com).
5
+
6
+ > **Status:** alpha (0.1.0). Parallel multi-region and cross-account scans, live pricing, six checks including metric-based idle detection with a hard cost cap.
7
+
8
+ ## Why this one
9
+ - **It can't change your account.** Every AWS call is `Describe*`, `List*` or `Get*`, enforced
10
+ three ways: in code, in tests, and in the IAM policy you attach.
11
+ - **It runs on your machine.** No SaaS, no agent, no telemetry. Nothing leaves your account.
12
+ - **You can read all of it.** Small codebase, minimal dependencies, published least-privilege
13
+ IAM policy.
14
+ - **It speaks dollars.** Every finding has a monthly cost and a savings estimate, priced from
15
+ the live AWS Price List API.
16
+
17
+ ## Install
18
+ ```bash
19
+ pipx install aws-waste-hunter # after the first PyPI release
20
+ docker build -t aws-waste-hunter . && docker run --rm -v ~/.aws:/home/scanner/.aws:ro \
21
+ aws-waste-hunter scan --region us-east-1 --profile my-sso-profile
22
+ pip install --require-hashes --no-deps -r requirements.lock && pip install --no-deps . # from source, hash-pinned
23
+ ```
24
+ See a [sample report](docs/sample-report.md) (fictional data).
25
+
26
+ ## Usage
27
+ ```bash
28
+ pip install -e .
29
+
30
+ aws-waste-hunter scan --region us-east-1 --profile my-sso-profile
31
+ aws-waste-hunter scan --regions us-east-1,eu-west-1 --format json --output report.json
32
+ aws-waste-hunter scan --all-regions
33
+ aws-waste-hunter scan --region us-east-1 --pricing offline # no Price List calls
34
+ aws-waste-hunter scan --region us-east-1 --max-metrics 50 # tighter CloudWatch cost cap
35
+ aws-waste-hunter scan --all-regions --concurrency 12 # parallel (default 8, max 16)
36
+
37
+ # Other accounts: assume a read-only role in each (repeat --role-arn for more accounts)
38
+ aws-waste-hunter scan --all-regions \
39
+ --role-arn arn:aws:iam::222222222222:role/aws-waste-hunter-scanner \
40
+ --external-id "$WASTE_HUNTER_EXTERNAL_ID"
41
+ ```
42
+ Create the cross-account role with the Terraform module in
43
+ [`terraform/scanner-role`](terraform/scanner-role): trust is limited to the principals you list
44
+ and requires an ExternalId; permissions are exactly [`iam/policy.json`](iam/policy.json).
45
+ Attach [`iam/policy.json`](iam/policy.json) to the role you scan with. Reports are written
46
+ with `0600` permissions because they describe your account.
47
+
48
+ ## Checks
49
+ | ID | Finds |
50
+ |---|---|
51
+ | `ebs-unattached` | EBS volumes not attached to anything |
52
+ | `ebs-gp2-to-gp3` | in-use gp2 volumes that could be gp3 (~20% cheaper) |
53
+ | `eip-unassociated` | Elastic IPs allocated but not associated |
54
+ | `logs-no-retention` | CloudWatch log groups that never expire |
55
+ | `nat-idle` | NAT gateways (older than 7 days) that moved 0 bytes in the last 7 days |
56
+ | `lb-idle` | Application/Network load balancers (older than 7 days) with no traffic in 7 days |
57
+
58
+ `nat-idle` and `lb-idle` read CloudWatch (`GetMetricData`, billed ~$0.01 per 1,000 metrics).
59
+ Every query is charged against a budget first: `--max-metrics` (default 200 per account and
60
+ region, about $0.002). If the cap is reached the check stops, keeps what it found, and reports
61
+ the error. Their dollar figures use us-east-1 list prices, so treat them as estimates.
62
+
63
+ A check that fails (for example a missing permission) is listed in the report and the exit
64
+ code is 1. It is never silently skipped.
65
+
66
+ ## Pricing
67
+ Prices come from the AWS Price List API per region, are cached for 24 hours, and fall back to
68
+ an offline us-east-1 list-price table if the lookup fails. Every report states which source
69
+ was used. Live and cached values must be positive and within a sane band of the reference, so
70
+ a bad parse or a tampered cache cannot inflate your numbers. Amounts are estimates, not quotes.
71
+
72
+ ## Security model
73
+ - Read-only guard on every call, plus a CI test that fails on any other operation.
74
+ - Least-privilege IAM policy with no wildcards; every check's required actions are
75
+ test-verified against it.
76
+ - AWS clients can only be created through one guarded helper (bounded timeouts, bounded
77
+ retries, validated region); a test fails if any other code creates a raw client.
78
+ - Region names are validated before they reach endpoints or file paths.
79
+ - Resource names and tags are treated as untrusted input when rendering reports.
80
+ - Cross-account scans use short-lived (1h) assumed-role credentials that stay in memory; the
81
+ only non-read operation allowed through the guard is the exact `sts:AssumeRole`.
82
+ - Standard AWS credential chain / SSO only. Credentials are never stored, logged or sent.
83
+ - GitHub Actions are pinned to commit SHAs.
84
+
85
+ See [SECURITY.md](SECURITY.md) to report a vulnerability.
86
+
87
+ ---
88
+
89
+ # Pro (planned)
90
+
91
+ The open-source scanner finds the mechanical waste. **Pro** is where it becomes a savings
92
+ program. These features are on the roadmap and are **not available yet**; the order below is
93
+ the rough build order.
94
+
95
+ ### Find more, across everything
96
+ - **Org-wide scans.** Cross-account scanning works today with `--role-arn`; Pro adds automatic
97
+ discovery of every account in your AWS Organization.
98
+ - **More metric-based idle detection.** Idle EC2 and RDS (NAT gateways and load balancers
99
+ are already in the open-source scanner). The waste that metadata alone can't show, with a hard cost cap
100
+ so the scan itself never surprises you.
101
+ - **EKS right-sizing.** Requests vs real usage from Datadog or Prometheus, plus the
102
+ autoscaler blockers that keep nodes alive. The same playbook behind a 70%+ node reduction.
103
+ - **Commitment review.** Savings Plans and Reserved Instance coverage, usually the single
104
+ biggest lever.
105
+
106
+ ### Fix it safely
107
+ - **Fix-as-code merge requests.** Generates the Terraform or CLI change as a GitLab or
108
+ GitHub MR for a human to review. It never applies anything itself.
109
+ - **Terraform cost guard.** Estimates the monthly cost of every `terraform plan` and flags
110
+ expensive patterns before they merge.
111
+ - **Suppressions with expiry.** Accept a finding per resource or tag, with an owner and a
112
+ review date, kept as policy-as-code in your repo.
113
+
114
+ ### Prove the savings
115
+ - **Trend history and scheduled scans.** Weekly digests to Slack or email and a running total
116
+ of dollars saved, so the program has numbers behind it.
117
+ - **AI prioritization in your own account.** Ranks findings by effort versus payoff using
118
+ Bedrock (or a local model). The AI only summarizes: it never detects and never acts, and
119
+ nothing leaves your account.
120
+ - **Export anywhere.** SARIF, CSV and Jira.
121
+
122
+ ### Don't want to run it yourself?
123
+ Helyx does manual, expert-led AWS reviews with a guaranteed 15% savings, and goes where
124
+ automation can't: architecture, data-transfer design and commitment strategy.
125
+ [Book a call](https://helyxit.com).
126
+
127
+ ## Develop
128
+ ```bash
129
+ python3.13 -m venv ~/.venvs/aws-waste-hunter && source ~/.venvs/aws-waste-hunter/bin/activate
130
+ pip install -e ".[dev]"
131
+ ruff check . && mypy src && pytest
132
+ ```
133
+ Tests use [moto](https://github.com/getmoto/moto) and canned Price List responses; no AWS
134
+ account or credentials needed.
135
+
136
+ ## License
137
+ Apache-2.0