Expand description
Phase 3: delete resources that --tag-session stamped during a session.
Discovery runs through AWS Resource Groups Tagging API, which is the
canonical cross-service way to list resources by tag. We then dispatch
per-service delete-* calls keyed off the ARN.
Credentials: this module shells out to the user’s aws CLI, which picks
up ambient credentials (AWS_PROFILE, env vars, instance role, etc.).
Cleanup runs OUTSIDE the expired session — by definition, the short-lived
STS creds are already gone by the time the user asks to clean up.
Structs§
- Cleanup
Report - Summary of a cleanup run.
- Cleanup
State - On-disk record of an in-flight cleanup. Written before any deletion happens, updated after each attempt, removed once nothing is left.
- Cleanup
State Store - Manages cleanup state files keyed by session id.
- Daily
Cost Hint - Rough daily-cost hint for a single tagged resource, used in the pre-delete preview so users can see “oh wait, that’s a $40/day RDS instance”.
- Orphaned
Session - One stale-session entry: the session already ended (expired / completed
/ failed / revoked) but still has resources tagged
tryaudex-sessionthat are alive in the account. - Tagged
Resource - A single tagged resource returned by Resource Groups Tagging API.
Enums§
- Delete
Outcome - The outcome of attempting to delete one resource.
Functions§
- cleanup_
session - Run
delete()over every discovered resource and aggregate results. - delete
- Attempt to delete a single resource.
dry_run=trueskips the actual call. - delete_
command - Build the aws-CLI argv to delete this resource. None if unsupported.
- delete_
tier - Delete priority for dependency ordering. Lower tiers are leaf resources (nothing else in our set refers to them) and get deleted first. Higher tiers sit upstream and must be torn down only after their dependents.
- discover
- Query Resource Groups Tagging API for every resource bearing
tryaudex-session=<session_id>. Returns the raw list (may be empty). - estimate_
daily_ cost - Look up a daily cost hint for the given resource, or None if it’s free / unknown. Prices are approximate us-east-1 list prices circa 2025 — precise to within “right order of magnitude”, nothing more.
- estimate_
daily_ cost_ total - Sum the known daily-cost floors across a set of resources. Returns (total_usd_per_day, any_usage_dependent).
- find_
orphans - Cross-reference the local session store with the tagging API to find
every non-active session that still has billing resources. Each entry
can be drained with
tryaudex cleanup <session_id>. - sort_
for_ deletion - Stable-sort resources into delete order. Same-tier ordering is preserved from the caller’s input (discovery order).