Skip to content

Add diff command and multi-account scanning#16

Closed
maksimov wants to merge 19 commits intomasterfrom
feature/diff-command
Closed

Add diff command and multi-account scanning#16
maksimov wants to merge 19 commits intomasterfrom
feature/diff-command

Conversation

@maksimov
Copy link
Copy Markdown
Collaborator

Summary

  • Diff command (gpuaudit diff <before.json> <after.json>): Compares two scan snapshots and reports new, removed, and changed GPU instances with cost deltas. Table and JSON output formats.
  • Multi-account AWS scanning: Scan multiple AWS accounts in a single invocation via STS AssumeRole (--targets) or automatic discovery via AWS Organizations (--org). Parallel scanning across targets and regions. Per-target summary tables in all output formats (table, markdown, Slack).
  • New CLI flags: --targets, --role, --external-id, --org, --skip-self
  • IAM policy output: gpuaudit iam-policy now includes cross-account (sts:AssumeRole) and Organizations (organizations:ListAccounts) policy statements
  • Bug fixes: K8s idle duration display, diff table box alignment, callerAccount identity when using --skip-self

Key design decisions

  • Provider-neutral flag names (--targets not --accounts) for future GCP/Azure support
  • Self account never uses AssumeRole — original credentials are preserved
  • Failed targets are warnings, not fatal — scan continues for reachable accounts
  • omitempty on new JSON fields ensures backward-compatible output for single-account scans
  • Severity classification deduplicated into models.MaxSeverity()

Test plan

  • All 42 tests pass (go test ./...)
  • go vet clean
  • go build succeeds
  • Manual test: single-account scan produces identical output to before
  • Manual test: multi-account scan with --targets and --role
  • Manual test: gpuaudit diff with two JSON snapshots

🤖 Generated with Claude Code

maksimov added 19 commits April 15, 2026 00:11
Compares two scan results by instance ID. Detects added, removed,
and changed instances across 6 fields (instance type, pricing model,
cost, state, GPU allocation, waste severity). Computes cost deltas.
gpuaudit diff old.json new.json [--format table|json]

Closes #5
The recommendation said "No GPU pods scheduled for X days" but X was
the node's total uptime, not the idle duration. We don't know when
the node became idle — only that it currently has zero GPU pods.
Changed wording to "Node up X days with 0 GPU pods scheduled."
Covers CLI flags (--targets, --role, --org), architecture for
parallel cross-account scanning via STS AssumeRole, output changes
with per-target sub-summaries, and IAM role setup docs (Terraform
+ CloudFormation).
Add ResolveTargets function that resolves scan targets based on
--targets, --org, --role, and --skip-self options. Self account uses
original credentials (no AssumeRole), failed assumptions are collected
as TargetError rather than being fatal.

Add STSClient and OrgClient interfaces, Target and TargetError types,
multi-target fields to ScanOptions, and organizations SDK dependency.

Includes 6 tests covering: self-only, explicit targets, skip-self,
partial failure, org discovery with suspended account filtering, and
self-in-targets deduplication.
ResolveTargets now returns selfAccount separately so Scan() always
gets the correct caller identity regardless of --skip-self. Extracted
models.MaxSeverity to replace three copies of severity classification.
Removed dead error return from scanTarget. Added missing copyright
headers.
@maksimov maksimov closed this Apr 18, 2026
@gpuaudit gpuaudit locked as resolved and limited conversation to collaborators Apr 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant