aws-finops-agent 1.0.1__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.
- aws_finops_agent-1.0.1/.github/ISSUE_TEMPLATE/bug_report.yml +45 -0
- aws_finops_agent-1.0.1/.github/ISSUE_TEMPLATE/config.yml +5 -0
- aws_finops_agent-1.0.1/.github/ISSUE_TEMPLATE/feature_request.yml +38 -0
- aws_finops_agent-1.0.1/.github/pull_request_template.md +15 -0
- aws_finops_agent-1.0.1/.github/workflows/ci.yml +33 -0
- aws_finops_agent-1.0.1/.github/workflows/release.yml +95 -0
- aws_finops_agent-1.0.1/.gitignore +19 -0
- aws_finops_agent-1.0.1/CHANGELOG.md +69 -0
- aws_finops_agent-1.0.1/CLAUDE.md +64 -0
- aws_finops_agent-1.0.1/CODE_OF_CONDUCT.md +135 -0
- aws_finops_agent-1.0.1/CONTRIBUTING.md +101 -0
- aws_finops_agent-1.0.1/LICENSE +21 -0
- aws_finops_agent-1.0.1/PKG-INFO +246 -0
- aws_finops_agent-1.0.1/README.md +216 -0
- aws_finops_agent-1.0.1/SECURITY.md +45 -0
- aws_finops_agent-1.0.1/docs/MCP.md +133 -0
- aws_finops_agent-1.0.1/iam/read-only-policy.json +164 -0
- aws_finops_agent-1.0.1/pyproject.toml +71 -0
- aws_finops_agent-1.0.1/scripts/release_notes.py +68 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/__init__.py +3 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyze.py +75 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/__init__.py +80 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/amazon_q_analyzer.py +117 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/analytics_analyzer.py +351 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/apigateway_analyzer.py +571 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/backup_analyzer.py +284 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/bedrock_analyzer.py +461 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/cloudfront_analyzer.py +292 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/cloudtrail_analyzer.py +169 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/cloudwatch_analyzer.py +276 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/codebuild_analyzer.py +138 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/config_analyzer.py +307 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/connect_analyzer.py +114 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/database_analyzer.py +278 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/directconnect_analyzer.py +667 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/documentdb_analyzer.py +231 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/ebs_analyzer.py +263 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/ec2_analyzer.py +849 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/ecr_analyzer.py +221 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/ecs_comprehensive_analyzer.py +962 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/eks_analyzer.py +1287 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/elasticache_analyzer.py +327 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/elb_analyzer.py +243 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/fargate_analyzer.py +366 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/function_adapter.py +162 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/guardduty_analyzer.py +311 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/inspector_analyzer.py +123 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/kms_analyzer.py +126 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/lambda_analyzer.py +284 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/macie_analyzer.py +398 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/messaging_analyzer.py +315 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/mq_analyzer.py +193 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/msk_analyzer.py +194 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/nat_gateway_analyzer.py +507 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/networking_analyzer.py +476 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/opensearch_analyzer.py +326 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/outposts_analyzer.py +81 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/rds_analyzer.py +339 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/redshift_analyzer.py +230 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/route53_analyzer.py +585 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/s3_analyzer.py +722 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/sagemaker_analyzer.py +543 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/storage_analyzer.py +427 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/support_analyzer.py +387 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/timestream_analyzer.py +139 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/transfer_analyzer.py +120 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/vpc_analyzer.py +224 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/waf_analyzer.py +243 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/workflow_analyzer.py +558 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/workspaces_analyzer.py +146 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/analyzers/xray_analyzer.py +95 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/aws/__init__.py +1 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/aws/context.py +159 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/aws/scan_scope.py +86 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/cli.py +618 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/config.py +29 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/data/__init__.py +1 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/data/fallback_pricing.py +323 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/discovery.py +141 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/identity.py +375 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/llm.py +577 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/mcp/__init__.py +4 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/mcp/server.py +179 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/mcp/tools.py +430 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/models.py +346 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/policy.py +185 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/progress.py +98 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/py.typed +0 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/report.py +729 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/review.py +495 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/savings.py +32 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/scan.py +136 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/service_mappings.py +111 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/services/__init__.py +1 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/services/analyzer_registry.py +521 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/services/aws_pricing_service.py +819 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/services/data_transfer_optimization_service.py +282 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/services/reserved_instance_recommender.py +313 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/services/right_sizing_service.py +317 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/services/savings_plans_service.py +120 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/utils/__init__.py +1 -0
- aws_finops_agent-1.0.1/src/aws_finops_agent/utils/js_number.py +140 -0
- aws_finops_agent-1.0.1/tests/aws_calls.py +336 -0
- aws_finops_agent-1.0.1/tests/conftest.py +48 -0
- aws_finops_agent-1.0.1/tests/test_analyze.py +116 -0
- aws_finops_agent-1.0.1/tests/test_analyzer_registry.py +469 -0
- aws_finops_agent-1.0.1/tests/test_aws_context.py +216 -0
- aws_finops_agent-1.0.1/tests/test_aws_pricing_service.py +246 -0
- aws_finops_agent-1.0.1/tests/test_aws_scan_scope.py +86 -0
- aws_finops_agent-1.0.1/tests/test_class_analyzers.py +280 -0
- aws_finops_agent-1.0.1/tests/test_cli.py +600 -0
- aws_finops_agent-1.0.1/tests/test_config.py +15 -0
- aws_finops_agent-1.0.1/tests/test_data_correctness.py +865 -0
- aws_finops_agent-1.0.1/tests/test_data_transfer_optimization_service.py +89 -0
- aws_finops_agent-1.0.1/tests/test_discovery.py +106 -0
- aws_finops_agent-1.0.1/tests/test_elasticache_analyzer.py +108 -0
- aws_finops_agent-1.0.1/tests/test_function_adapter.py +92 -0
- aws_finops_agent-1.0.1/tests/test_function_analyzers_compute.py +439 -0
- aws_finops_agent-1.0.1/tests/test_function_analyzers_network.py +681 -0
- aws_finops_agent-1.0.1/tests/test_function_analyzers_platform.py +629 -0
- aws_finops_agent-1.0.1/tests/test_identity.py +290 -0
- aws_finops_agent-1.0.1/tests/test_js_number.py +56 -0
- aws_finops_agent-1.0.1/tests/test_llm.py +444 -0
- aws_finops_agent-1.0.1/tests/test_mcp.py +437 -0
- aws_finops_agent-1.0.1/tests/test_models.py +24 -0
- aws_finops_agent-1.0.1/tests/test_package.py +7 -0
- aws_finops_agent-1.0.1/tests/test_policy.py +114 -0
- aws_finops_agent-1.0.1/tests/test_price_cache.py +199 -0
- aws_finops_agent-1.0.1/tests/test_readonly.py +158 -0
- aws_finops_agent-1.0.1/tests/test_release_notes.py +81 -0
- aws_finops_agent-1.0.1/tests/test_report.py +453 -0
- aws_finops_agent-1.0.1/tests/test_reserved_instance_recommender.py +126 -0
- aws_finops_agent-1.0.1/tests/test_review.py +408 -0
- aws_finops_agent-1.0.1/tests/test_right_sizing_service.py +70 -0
- aws_finops_agent-1.0.1/tests/test_savings.py +36 -0
- aws_finops_agent-1.0.1/tests/test_savings_plans_service.py +92 -0
- aws_finops_agent-1.0.1/tests/test_tag_policy.py +138 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: Bug report
|
|
2
|
+
description: A crash, a wrong finding or amount, or output that does not match the docs.
|
|
3
|
+
labels: ["bug"]
|
|
4
|
+
body:
|
|
5
|
+
- type: markdown
|
|
6
|
+
attributes:
|
|
7
|
+
value: |
|
|
8
|
+
Security issues go through private reporting, not here. See [SECURITY.md](https://github.com/gutehall/aws-finops-agent/blob/main/SECURITY.md).
|
|
9
|
+
|
|
10
|
+
Do not paste AWS keys, account ids, resource ids or report files. Redact them.
|
|
11
|
+
- type: input
|
|
12
|
+
id: version
|
|
13
|
+
attributes:
|
|
14
|
+
label: Version
|
|
15
|
+
description: Output of `aws-finops-agent --version`, and how you installed it (PyPI, pipx, git tag).
|
|
16
|
+
validations:
|
|
17
|
+
required: true
|
|
18
|
+
- type: input
|
|
19
|
+
id: environment
|
|
20
|
+
attributes:
|
|
21
|
+
label: Environment
|
|
22
|
+
description: OS and Python version. With a model review, the model and server (Ollama or OpenAI-compatible).
|
|
23
|
+
validations:
|
|
24
|
+
required: true
|
|
25
|
+
- type: textarea
|
|
26
|
+
id: command
|
|
27
|
+
attributes:
|
|
28
|
+
label: Command
|
|
29
|
+
description: The command you ran, with flags. Replace the profile name if it is sensitive.
|
|
30
|
+
render: shell
|
|
31
|
+
validations:
|
|
32
|
+
required: true
|
|
33
|
+
- type: textarea
|
|
34
|
+
id: what-happened
|
|
35
|
+
attributes:
|
|
36
|
+
label: What happened
|
|
37
|
+
description: What you saw, and what you expected instead. For a wrong finding, name the analyzer and the price source the card shows.
|
|
38
|
+
validations:
|
|
39
|
+
required: true
|
|
40
|
+
- type: textarea
|
|
41
|
+
id: output
|
|
42
|
+
attributes:
|
|
43
|
+
label: Terminal output or traceback
|
|
44
|
+
description: Run with `LOG_LEVEL=info` if you can. Redact account data.
|
|
45
|
+
render: text
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: Feature or analyzer request
|
|
2
|
+
description: A new analyzer, a new check in an existing analyzer, or another improvement.
|
|
3
|
+
labels: ["enhancement"]
|
|
4
|
+
body:
|
|
5
|
+
- type: markdown
|
|
6
|
+
attributes:
|
|
7
|
+
value: |
|
|
8
|
+
The scan stays read-only: it calls only Describe, Get, List and BatchGet APIs, and never changes your account. Requests to remediate resources or assume roles are out of scope.
|
|
9
|
+
- type: dropdown
|
|
10
|
+
id: kind
|
|
11
|
+
attributes:
|
|
12
|
+
label: Kind
|
|
13
|
+
options:
|
|
14
|
+
- New analyzer for a service
|
|
15
|
+
- New check in an existing analyzer
|
|
16
|
+
- Report or CLI improvement
|
|
17
|
+
- Other
|
|
18
|
+
validations:
|
|
19
|
+
required: true
|
|
20
|
+
- type: textarea
|
|
21
|
+
id: problem
|
|
22
|
+
attributes:
|
|
23
|
+
label: Problem
|
|
24
|
+
description: What waste or saving is missed today, or what is hard to do? Include rough spend if it helps show the value.
|
|
25
|
+
validations:
|
|
26
|
+
required: true
|
|
27
|
+
- type: textarea
|
|
28
|
+
id: proposal
|
|
29
|
+
attributes:
|
|
30
|
+
label: Proposal
|
|
31
|
+
description: What should the tool find or show? For an analyzer, name the AWS service as Cost Explorer shows it.
|
|
32
|
+
validations:
|
|
33
|
+
required: true
|
|
34
|
+
- type: textarea
|
|
35
|
+
id: aws-calls
|
|
36
|
+
attributes:
|
|
37
|
+
label: AWS calls needed
|
|
38
|
+
description: The read-only API calls and IAM actions the check needs, if you know them (for example `ec2:DescribeVolumes`).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## What and why
|
|
2
|
+
|
|
3
|
+
<!-- What this changes, and why. Link the issue it fixes, if any. -->
|
|
4
|
+
|
|
5
|
+
## Checklist
|
|
6
|
+
|
|
7
|
+
- [ ] `.venv/bin/pytest -q` passes
|
|
8
|
+
- [ ] `.venv/bin/ruff check src tests scripts` passes
|
|
9
|
+
- [ ] `.venv/bin/mypy src` passes
|
|
10
|
+
- [ ] Tests cover the change
|
|
11
|
+
- [ ] AWS calls added or removed: `iam/read-only-policy.json` updated to match (`tests/test_policy.py`)
|
|
12
|
+
- [ ] User-facing change (CLI flag, report, config, analyzer): `README.md` and `CHANGELOG.md` updated
|
|
13
|
+
- [ ] No real AWS keys, account ids or report data in code, tests or fixtures
|
|
14
|
+
|
|
15
|
+
Security issues go through private reporting, not pull requests. See [SECURITY.md](https://github.com/gutehall/aws-finops-agent/blob/main/SECURITY.md).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
python:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: true
|
|
16
|
+
matrix:
|
|
17
|
+
python-version: ["3.11", "3.12"]
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v7
|
|
20
|
+
- uses: actions/setup-python@v7
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: |
|
|
25
|
+
python -m venv .venv
|
|
26
|
+
.venv/bin/pip install -U pip
|
|
27
|
+
.venv/bin/pip install -e ".[dev]"
|
|
28
|
+
- name: Test (pytest)
|
|
29
|
+
run: .venv/bin/pytest -q
|
|
30
|
+
- name: Lint (ruff)
|
|
31
|
+
run: .venv/bin/ruff check src tests scripts
|
|
32
|
+
- name: Type check (mypy)
|
|
33
|
+
run: .venv/bin/mypy src
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Publish a GitHub release, and the same version to PyPI, when a version tag is pushed.
|
|
2
|
+
# The tag is pushed by hand (see CONTRIBUTING.md#releases); this workflow never creates or
|
|
3
|
+
# moves a tag, and leaves an existing release alone.
|
|
4
|
+
name: Release
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
tags: ["v*"]
|
|
9
|
+
|
|
10
|
+
permissions: {}
|
|
11
|
+
|
|
12
|
+
concurrency:
|
|
13
|
+
group: release-${{ github.ref_name }}
|
|
14
|
+
cancel-in-progress: false
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
release:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
permissions:
|
|
20
|
+
contents: write
|
|
21
|
+
outputs:
|
|
22
|
+
created: ${{ steps.existing.outputs.exists == 'false' }}
|
|
23
|
+
env:
|
|
24
|
+
TAG: ${{ github.ref_name }}
|
|
25
|
+
GH_TOKEN: ${{ github.token }}
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
28
|
+
with:
|
|
29
|
+
fetch-depth: 0
|
|
30
|
+
|
|
31
|
+
- name: Skip if the release already exists
|
|
32
|
+
id: existing
|
|
33
|
+
run: |
|
|
34
|
+
if gh release view "$TAG" >/dev/null 2>&1; then
|
|
35
|
+
echo "Release $TAG already exists; leaving it alone."
|
|
36
|
+
echo "exists=true" >> "$GITHUB_OUTPUT"
|
|
37
|
+
else
|
|
38
|
+
echo "exists=false" >> "$GITHUB_OUTPUT"
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
- name: Check the tag is on main
|
|
42
|
+
if: steps.existing.outputs.exists == 'false'
|
|
43
|
+
run: |
|
|
44
|
+
git fetch origin +refs/heads/main:refs/remotes/origin/main
|
|
45
|
+
commit=$(git rev-parse "$TAG^{commit}")
|
|
46
|
+
git merge-base --is-ancestor "$commit" origin/main \
|
|
47
|
+
|| { echo "$TAG ($commit) is not on main"; exit 1; }
|
|
48
|
+
|
|
49
|
+
- name: Build notes from CHANGELOG.md
|
|
50
|
+
if: steps.existing.outputs.exists == 'false'
|
|
51
|
+
run: python3 scripts/release_notes.py "$TAG" > "$RUNNER_TEMP/notes.md"
|
|
52
|
+
|
|
53
|
+
- name: Create the release
|
|
54
|
+
if: steps.existing.outputs.exists == 'false'
|
|
55
|
+
run: gh release create "$TAG" --verify-tag --title "$TAG" --notes-file "$RUNNER_TEMP/notes.md"
|
|
56
|
+
|
|
57
|
+
# Same tag, same commit. Trusted publishing: the id-token is minted only in this job.
|
|
58
|
+
# Off until the repository variable PUBLISH_TO_PYPI is 'true', which needs a PyPI trusted
|
|
59
|
+
# publisher registered for this repository, workflow and the pypi environment.
|
|
60
|
+
pypi:
|
|
61
|
+
needs: release
|
|
62
|
+
if: needs.release.outputs.created == 'true' && vars.PUBLISH_TO_PYPI == 'true'
|
|
63
|
+
runs-on: ubuntu-latest
|
|
64
|
+
environment: pypi
|
|
65
|
+
permissions:
|
|
66
|
+
contents: read
|
|
67
|
+
id-token: write
|
|
68
|
+
env:
|
|
69
|
+
TAG: ${{ github.ref_name }}
|
|
70
|
+
steps:
|
|
71
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
72
|
+
|
|
73
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
74
|
+
with:
|
|
75
|
+
python-version: "3.12"
|
|
76
|
+
|
|
77
|
+
- name: Build the sdist and wheel
|
|
78
|
+
run: |
|
|
79
|
+
python -m pip install build
|
|
80
|
+
python -m build
|
|
81
|
+
|
|
82
|
+
- name: Check the built version is the tag
|
|
83
|
+
run: |
|
|
84
|
+
python - <<'PY'
|
|
85
|
+
import glob, os, sys
|
|
86
|
+
tag = os.environ["TAG"].removeprefix("v")
|
|
87
|
+
ok = (f"aws_finops_agent-{tag}.tar.gz", f"aws_finops_agent-{tag}-")
|
|
88
|
+
bad = [f for f in glob.glob("dist/*")
|
|
89
|
+
if not (os.path.basename(f) == ok[0] or os.path.basename(f).startswith(ok[1]))]
|
|
90
|
+
if bad or not glob.glob("dist/*"):
|
|
91
|
+
sys.exit(f"dist does not match tag {tag}: {bad}")
|
|
92
|
+
PY
|
|
93
|
+
|
|
94
|
+
- name: Publish to PyPI
|
|
95
|
+
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
*.log
|
|
2
|
+
report*.html
|
|
3
|
+
.venv/
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.egg-info/
|
|
6
|
+
build/
|
|
7
|
+
.pytest_cache/
|
|
8
|
+
.mypy_cache/
|
|
9
|
+
.ruff_cache/
|
|
10
|
+
dist/
|
|
11
|
+
node_modules/
|
|
12
|
+
.coverage
|
|
13
|
+
htmlcov/
|
|
14
|
+
.env
|
|
15
|
+
.env.*
|
|
16
|
+
!.env.example
|
|
17
|
+
.linear
|
|
18
|
+
.DS_Store
|
|
19
|
+
aws-finops-report.html
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## v1.0.1
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Dropped findings: the function-analyzer adapter now maps `SCALE` and `OPTIMIZE_MEMORY` to right-sizing, so Redshift and EKS node downsizes and Lambda memory right-sizing reach the report and the totals. `resource_count` counts only the findings that are kept. (#10)
|
|
7
|
+
- Lambda: an uninvoked function is reported as waste first. The zero-savings timeout suggestion is removed. (#10)
|
|
8
|
+
- Spend view: analyzed services (e.g. `AWS Lambda`) and sibling services that share one analyzer (Step Functions, EventBridge) now show as run, not "not run". (#10)
|
|
9
|
+
- Estimates: API Gateway cache savings and the HTTP API migration estimate scale 7-day requests to a month (`30/7`). The ELB LCU estimate uses average processed GB per hour × 730 h. (#10)
|
|
10
|
+
- Failed analyzers: a function analyzer whose main listing call fails now shows a failed-analyzer warning, not "no savings". An analyzer that covers several sub-services fails as a whole when one sub-service listing is denied. (#10)
|
|
11
|
+
- Savings Plans: only access denied is cached as "no plans". Other errors are retried on the next lookup. (#10)
|
|
12
|
+
- MCP: the `scan_account` cache key includes `concurrency`. (#10)
|
|
13
|
+
|
|
14
|
+
### Documentation
|
|
15
|
+
- Added SECURITY.md, CODE_OF_CONDUCT.md, and issue and PR templates. The README now states scope, limitations and license. (#11)
|
|
16
|
+
- The LICENSE copyright holder is now Mathias Gutehall, matching the package metadata.
|
|
17
|
+
|
|
18
|
+
## v1.0.0
|
|
19
|
+
|
|
20
|
+
### Breaking Changes
|
|
21
|
+
- Report schema (`--json` and HTML): findings can have `kind: "governance"`, and findings gain optional `missingTags` and `environment` fields. They appear only when a tag policy is configured. Without a policy, the report keys are unchanged; amounts change as listed under Fixed. (#7)
|
|
22
|
+
- `iam/read-only-policy.json` adds `backup:ListBackupPlans`, `backup:GetBackupPlan`, `events:ListArchives`, `ecs:ListContainerInstances` and `kms:GetKeyRotationStatus`. Update the policy attached to your scan role or user, or those checks fail with access denied.
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- Tag policy (optional): set it in `./finops-policy.json`, `FINOPS_POLICY_FILE`, or `FINOPS_*` env vars. Each resource missing required tag keys gets one $0 governance finding. These findings are kept regardless of `--min-savings` and never counted in totals. Findings tagged with a non-prod environment are sorted after prod findings. Invalid config is ignored with a warning. (#7)
|
|
26
|
+
- MCP server: the optional extra `mcp` adds the `aws-finops-agent-mcp` stdio server. It offers `scan_account`, `get_finding`, `get_analyzer` and `list_analyzers`. See `docs/MCP.md`. (#8)
|
|
27
|
+
- Retention checks: CloudWatch log groups with no retention are flagged at any size. Backup plans with no delete-after lifecycle and EventBridge archives with no retention are also flagged. (#5)
|
|
28
|
+
- Persistent price cache: live price quotes are stored in a local SQLite file with a TTL. Settings: `FINOPS_AGENT_PRICE_CACHE`, `FINOPS_AGENT_PRICE_CACHE_PATH` and `FINOPS_AGENT_PRICE_CACHE_TTL_HOURS` (default 24). (#6)
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
- Ollama review is faster and deterministic. It uses a pooled session, a cached model lookup and model ranking. It also sends JSON Schema structured outputs, uses temperature 0, and picks one context size per review. New env vars: `OLLAMA_CONCURRENCY`, `OLLAMA_TEMPERATURE`, `OLLAMA_KEEP_ALIVE`, `OLLAMA_THINK` and `OLLAMA_NUM_CTX`. (#3)
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
- Pricing, metrics and math across analyzers:
|
|
35
|
+
- SageMaker, Fargate and non-hourly Price List units no longer inflate monthly cost 730x.
|
|
36
|
+
- Right-sizing and RI math is corrected.
|
|
37
|
+
- CloudWatch namespaces, dimensions and regions are corrected.
|
|
38
|
+
- The same saving is no longer counted twice across analyzers.
|
|
39
|
+
- Duplicates keep the larger saving, and resources match by exact ARN.
|
|
40
|
+
- Truncated AWS API calls are now fully paginated.
|
|
41
|
+
|
|
42
|
+
## v0.2.0
|
|
43
|
+
|
|
44
|
+
First Python release.
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
- `--version` prints the package version and exits 0.
|
|
48
|
+
- Releases: each `vX.Y.Z` tag on `main` publishes a GitHub release with its changelog section as notes, and uploads the sdist and wheel to PyPI through trusted publishing when that is enabled. See CONTRIBUTING.md.
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
- Profiles with `mfa_serial` ask for the MFA code once per run, on stderr, and fail clearly when stdin is not a terminal.
|
|
52
|
+
- SQS: the price is looked up once per queue type and region, so a failed lookup warns once. Monthly cost now scales the 7-day metric window to 30 days, and the reasoning says "7 days".
|
|
53
|
+
- Findings that save $0.00/mo no longer appear in the top lists of the report and the terminal summary.
|
|
54
|
+
- Cost Explorer names "EC2 - Other", "Amazon Elastic Load Balancing", "AmazonCloudWatch" and "Amazon EC2 Container Registry (ECR)" now run their analyzers.
|
|
55
|
+
|
|
56
|
+
### Changed
|
|
57
|
+
- Rewritten in Python: same CLI flags, exit codes, read-only scan, HTML and JSON report, and local model review. Requires Python 3.11 or later; Node.js is no longer used.
|
|
58
|
+
- `iam/read-only-policy.json` drops seven actions the scan never called: `ec2:DescribeReservedInstances`, `elasticmapreduce:DescribeCluster`, `outposts:ListSites`, `route53:GetHealthCheck`, `s3:GetBucketTagging`, `s3:GetIntelligentTieringConfiguration`, `workspaces:DescribeWorkspaceBundles`.
|
|
59
|
+
|
|
60
|
+
## v0.1.0 — 2026-11-26
|
|
61
|
+
|
|
62
|
+
First public release.
|
|
63
|
+
|
|
64
|
+
### Features
|
|
65
|
+
- CLI and AWS session: profile and region flags, progress output, and a terminal summary
|
|
66
|
+
- Discovery and analyzers: Cost Explorer inventory, service analyzers, live prices, and resource identity
|
|
67
|
+
- Ollama review: self-hosted LLM client, finding verdicts, and service notes
|
|
68
|
+
- HTML report: self-contained savings page and JSON output
|
|
69
|
+
- Read-only IAM policy, README, and scan-boundary tests
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## What this is
|
|
6
|
+
|
|
7
|
+
`aws-finops-agent`: a local, read-only Python CLI that scans one AWS account (via the user's own profile) and writes a self-contained HTML report of cost savings. An optional self-hosted LLM (Ollama or OpenAI-compatible) labels findings but never changes findings, amounts, or totals. The package is a port of an earlier TypeScript CLI (see "JS number semantics" below).
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
Setup (Python 3.11+):
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
python -m venv .venv
|
|
15
|
+
.venv/bin/pip install -e ".[dev]"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Checks (CI runs these on Python 3.11 and 3.12):
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
.venv/bin/pytest -q
|
|
22
|
+
.venv/bin/ruff check src tests scripts
|
|
23
|
+
.venv/bin/mypy src
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Single test: `.venv/bin/pytest -q tests/test_readonly.py::test_name` or `-k <expr>`.
|
|
27
|
+
|
|
28
|
+
Run the CLI: `.venv/bin/aws-finops-agent --profile <p> --regions eu-west-1 --no-llm --out report.html`.
|
|
29
|
+
|
|
30
|
+
## Scan pipeline
|
|
31
|
+
|
|
32
|
+
`cli._scan` drives one scan, loading each step lazily via `_step(module, name)`:
|
|
33
|
+
|
|
34
|
+
1. `aws.context.ScanContext`: the boto3 session and active region. `sts:GetCallerIdentity` gives the account id.
|
|
35
|
+
2. `discovery.discover_services`: Cost Explorer is the only cost source. It yields billed services with spend; `service_mappings.SERVICE_MAPPINGS` maps Cost Explorer names to friendly names and flags `has_analyzer`.
|
|
36
|
+
3. `analyze.analyze_services`: global analyzers run once, then regional analyzers run once per region (`ctx.use(region)` switches only between passes). Within a pass, highest-spend services start first, bounded by `--concurrency`. Results are joined once with `identity.join_identity` (names/tags, Tagging API fill-in, drops `CostOptimization=disabled` resources).
|
|
37
|
+
4. `review.review_findings` + `llm.LLMClient`: optional model verdicts (`confirm` / `false_positive` / `unsure`) and unverified notes.
|
|
38
|
+
5. `report.build_report` then `render_html` / `render_json`. The HTML must stay a single file with inline CSS/JS, no external loads, and readable with JavaScript off.
|
|
39
|
+
|
|
40
|
+
## Analyzers
|
|
41
|
+
|
|
42
|
+
- One module per analyzer in `src/aws_finops_agent/analyzers/`. The contract is in the docstring of `analyzers/__init__.py`: read it before adding or changing one.
|
|
43
|
+
- Two kinds: **class** analyzers (implement the `ServiceAnalyzer` protocol; no-arg constructor that must not call AWS) and **function** analyzers (return `list[OptimizationRecommendation]`, wrapped by `FunctionBasedAnalyzerAdapter`: RESIZE/MODIFY/SCALE/OPTIMIZE_MEMORY become right-sizing, TERMINATE becomes waste, other actions are dropped). ECS is a special case wrapped by `EcsAnalyzer`.
|
|
44
|
+
- Register a new analyzer in `BUILT_IN_ANALYZERS` in `services/analyzer_registry.py` (scope `regional` or `global`), and set `has_analyzer=True` on its `SERVICE_MAPPINGS` entry.
|
|
45
|
+
- Analyzers raise on AWS errors. The registry turns the exception into a failed result that the CLI shows as a warning; the other analyzers continue.
|
|
46
|
+
- Pricing: `services/aws_pricing_service.py` uses the live Price List API, with embedded fallbacks in `data/fallback_pricing.py`. Each finding records its price source. Commitment (RI / Savings Plan) recommendations are totalled separately from waste.
|
|
47
|
+
|
|
48
|
+
## AWS access rules (enforced by tests)
|
|
49
|
+
|
|
50
|
+
- Only `aws/context.py` imports boto3 or builds clients. Elsewhere, declare module-level handles with `regional_client("svc")` / `global_client("svc")` from `aws.scan_scope`. These resolve via a ContextVar to the active scan and region; worker threads run in a copied context. Do not build clients or read `AWS_REGION` directly. Do not pass client handles to other functions.
|
|
51
|
+
- Read-only: call only `describe_*`, `get_*`, `list_*`, `batch_get_*` methods, and pass `get_paginator` a string literal. Never create SSM, Secrets Manager, DynamoDB, SNS, or Athena clients. Never mention `put_item` or `assume_role`. `tests/test_readonly.py` statically scans the source (shared helper `tests/aws_calls.py`).
|
|
52
|
+
- Every AWS action called must be in `iam/read-only-policy.json`, and the policy must grant no extra action except the documented ones (`ce:GetCostForecast`, `timestream:DescribeEndpoints`, `ecs:ListTagsForResource`). `tests/test_policy.py` checks both directions. Add or remove actions together with the code.
|
|
53
|
+
- Tests isolate boto3 from `~/.aws` with the `aws_env` fixture in `tests/conftest.py`.
|
|
54
|
+
|
|
55
|
+
## JS number semantics
|
|
56
|
+
|
|
57
|
+
`utils/js_number.py` reproduces TypeScript behavior (`Math.round`, `toFixed`, `parseFloat`, template formatting) so prices, savings, and text match the old CLI. Use these helpers, not Python's `round`/`str`, for anything user-visible.
|
|
58
|
+
|
|
59
|
+
## Releases
|
|
60
|
+
|
|
61
|
+
- The version lives only in `__version__` in `src/aws_finops_agent/__init__.py`.
|
|
62
|
+
- A release PR sets the version, adds a `## vX.Y.Z` section at the top of `CHANGELOG.md`, and updates the `==X.Y.Z` / `@vX.Y.Z` pins in `README.md`. After merge, tag `main` by hand. `release.yml` validates the tag via `scripts/release_notes.py`.
|
|
63
|
+
- Bump rules: major for a CLI flag or report schema (HTML or `--json`) change, minor for a new analyzer, patch for fixes only.
|
|
64
|
+
- Never move or force-push tags.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
+
community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
+
any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
|
35
|
+
without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement privately,
|
|
63
|
+
through GitHub's private reporting form for this repository:
|
|
64
|
+
<https://github.com/gutehall/aws-finops-agent/security/advisories/new>. Start
|
|
65
|
+
the title with "Code of conduct" so the report is not mistaken for a
|
|
66
|
+
vulnerability. Reports are read only by the maintainers.
|
|
67
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
68
|
+
|
|
69
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
70
|
+
reporter of any incident.
|
|
71
|
+
|
|
72
|
+
## Enforcement Guidelines
|
|
73
|
+
|
|
74
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
75
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
76
|
+
|
|
77
|
+
### 1. Correction
|
|
78
|
+
|
|
79
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
80
|
+
unprofessional or unwelcome in the community.
|
|
81
|
+
|
|
82
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
83
|
+
clarity around the nature of the violation and an explanation of why the
|
|
84
|
+
behavior was inappropriate. A public apology may be requested.
|
|
85
|
+
|
|
86
|
+
### 2. Warning
|
|
87
|
+
|
|
88
|
+
**Community Impact**: A violation through a single incident or series of
|
|
89
|
+
actions.
|
|
90
|
+
|
|
91
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
92
|
+
interaction with the people involved, including unsolicited interaction with
|
|
93
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
94
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
95
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
|
96
|
+
ban.
|
|
97
|
+
|
|
98
|
+
### 3. Temporary Ban
|
|
99
|
+
|
|
100
|
+
**Community Impact**: A serious violation of community standards, including
|
|
101
|
+
sustained inappropriate behavior.
|
|
102
|
+
|
|
103
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
104
|
+
communication with the community for a specified period of time. No public or
|
|
105
|
+
private interaction with the people involved, including unsolicited interaction
|
|
106
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
107
|
+
Violating these terms may lead to a permanent ban.
|
|
108
|
+
|
|
109
|
+
### 4. Permanent Ban
|
|
110
|
+
|
|
111
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
112
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
113
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
114
|
+
|
|
115
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
|
116
|
+
community.
|
|
117
|
+
|
|
118
|
+
## Attribution
|
|
119
|
+
|
|
120
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
121
|
+
version 2.1, available at
|
|
122
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
123
|
+
|
|
124
|
+
Community Impact Guidelines were inspired by
|
|
125
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
126
|
+
|
|
127
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
128
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
|
129
|
+
[https://www.contributor-covenant.org/translations][translations].
|
|
130
|
+
|
|
131
|
+
[homepage]: https://www.contributor-covenant.org
|
|
132
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
133
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
134
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
|
135
|
+
[translations]: https://www.contributor-covenant.org/translations
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for helping. Bug reports, analyzer requests and pull requests are all welcome. Everyone taking part follows the [code of conduct](CODE_OF_CONDUCT.md). Report security issues privately, as described in [SECURITY.md](SECURITY.md), never in a public issue or pull request.
|
|
4
|
+
|
|
5
|
+
## Propose a change
|
|
6
|
+
|
|
7
|
+
1. For anything larger than a small fix, open an issue first, so we can agree on the approach before you write code.
|
|
8
|
+
2. Fork the repository and create a branch from `main`.
|
|
9
|
+
3. Set up the dev environment and make your change, with tests (see below).
|
|
10
|
+
4. Run the three checks. CI runs the same ones and must pass.
|
|
11
|
+
5. Open a pull request against `main` and fill in the checklist. If the change is user-facing, update `README.md` and add a line to `CHANGELOG.md`.
|
|
12
|
+
|
|
13
|
+
Never put real AWS keys, account ids or report data in code, tests, fixtures or issues. Tests run against stubbed AWS clients, so you do not need an AWS account to contribute.
|
|
14
|
+
|
|
15
|
+
## Development setup
|
|
16
|
+
|
|
17
|
+
You need Python 3.11 or newer.
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
python -m venv .venv
|
|
21
|
+
.venv/bin/pip install -e ".[dev]"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Run the checks before you open a pull request. CI runs the same three:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
.venv/bin/pytest -q
|
|
28
|
+
.venv/bin/ruff check src tests scripts
|
|
29
|
+
.venv/bin/mypy src
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Analyzers
|
|
33
|
+
|
|
34
|
+
Analyzers live in `src/aws_finops_agent/analyzers/`, one module per analyzer. The
|
|
35
|
+
docstring of `src/aws_finops_agent/analyzers/__init__.py` describes the contract: the two
|
|
36
|
+
kinds of analyzer module, what they return, and how the registry loads them. Register a
|
|
37
|
+
new analyzer in `BUILT_IN_ANALYZERS` in `src/aws_finops_agent/services/analyzer_registry.py`.
|
|
38
|
+
|
|
39
|
+
## AWS access
|
|
40
|
+
|
|
41
|
+
Only `src/aws_finops_agent/aws/context.py` imports boto3 and creates clients. Everywhere
|
|
42
|
+
else, declare a client handle at module level with `regional_client` or `global_client`
|
|
43
|
+
from `aws_finops_agent.aws.scan_scope`, and call methods on it directly:
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from aws_finops_agent.aws.scan_scope import regional_client
|
|
47
|
+
|
|
48
|
+
ec2_client = regional_client("ec2")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def list_volumes() -> list[dict]:
|
|
52
|
+
volumes = []
|
|
53
|
+
for page in ec2_client.get_paginator("describe_volumes").paginate():
|
|
54
|
+
volumes.extend(page.get("Volumes") or [])
|
|
55
|
+
return volumes
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The scan is read-only. Call only methods that start with `describe_`, `get_`, `list_`, or
|
|
59
|
+
`batch_get_`, and pass the operation to `get_paginator` as a string literal. Do not pass a
|
|
60
|
+
client handle to other functions. `tests/test_readonly.py` checks all of this.
|
|
61
|
+
|
|
62
|
+
When you add a call, add its IAM action to `iam/read-only-policy.json`. When you remove
|
|
63
|
+
the last call to an action, remove the action. `tests/test_policy.py` fails if the policy
|
|
64
|
+
and the code disagree.
|
|
65
|
+
|
|
66
|
+
## Releases (maintainers)
|
|
67
|
+
|
|
68
|
+
This section is for maintainers. Contributors do not need to bump the version or tag anything.
|
|
69
|
+
|
|
70
|
+
Releases come from `main` as a `vX.Y.Z` tag. Not every merge needs one.
|
|
71
|
+
|
|
72
|
+
- **Bump rules:**
|
|
73
|
+
- **Major:** a CLI flag change or a report schema change (HTML or `--json` output).
|
|
74
|
+
- **Minor:** a new analyzer.
|
|
75
|
+
- **Patch:** fixes only.
|
|
76
|
+
- If a release mixes these, the largest bump wins.
|
|
77
|
+
- **One number everywhere:** the version is set only in `__version__` in
|
|
78
|
+
`src/aws_finops_agent/__init__.py`. `pyproject.toml` reads it from there, and
|
|
79
|
+
`aws-finops-agent --version` prints it.
|
|
80
|
+
- **Cutting a release:** in one pull request, set `__version__`, add a `## vX.Y.Z` section
|
|
81
|
+
at the top of `CHANGELOG.md`, and update the `==X.Y.Z` and `@vX.Y.Z` pins in `README.md`.
|
|
82
|
+
Merge it to `main`. Then tag the merged `main` by hand and push the tag:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
git switch main && git pull --ff-only
|
|
86
|
+
git tag -a vX.Y.Z -m vX.Y.Z
|
|
87
|
+
git push origin vX.Y.Z
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
- **What the `Release` workflow does** (`.github/workflows/release.yml`): it skips a tag
|
|
91
|
+
that already has a release, fails if the tag commit is not on `main`, and fails if
|
|
92
|
+
`scripts/release_notes.py` finds the tag is not `vX.Y.Z`, does not match `__version__`,
|
|
93
|
+
or has no changelog section. Otherwise it creates the GitHub release with that section
|
|
94
|
+
as notes. It never creates or moves a tag.
|
|
95
|
+
- **PyPI:** the `pypi` job builds the sdist and wheel, refuses a file whose version is not
|
|
96
|
+
the tag, and uploads through trusted publishing. No API token is stored. It runs only
|
|
97
|
+
when the release was created in the same run and the repository variable
|
|
98
|
+
`PUBLISH_TO_PYPI` is `true`. Before setting that variable, register a trusted publisher
|
|
99
|
+
on PyPI for this repository, the `release.yml` workflow, and the `pypi` environment.
|
|
100
|
+
- **Tags are immutable:** never force-push or move a tag. If a release is wrong, fix it on
|
|
101
|
+
`main` and cut the next patch.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mathias Gutehall
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|