Portfolio-ready AWS cleanup tool with safe defaults, dry-run first, and a live CLI view.
- Multi-service cleanup for S3, EC2, Lambda, EBS, CloudWatch, and IAM
- Dry-run by default;
--applyrequired for deletions - Filters: prefixes, target/ignore lists, optional tag requirement
- Age gates for buckets/objects; supports versioned buckets
- Live Rich table (opt-out with
--no-live) plus JSON output when needed - Safety switches to guard zero retention and delete-all modes
- Interactive per-bucket approval and batched deletes
python3 -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install -e ".[dev]"Runtime-only (no dev tools):
pip install -e .Copy config.example.yaml to config.yaml and adjust:
bucket_prefixes,target_buckets,ignore_bucketsbucket_retention_days,object_retention_days,delete_all_objectsinclude_versioned_objects,delete_empty_buckets- Optional
require_tag: { key, value }
Dry-run (default):
python -m aws_automations.s3_cleanup --config config.yamlPlan view (no apply) with live table on TTY:
python -m aws_automations.s3_cleanup --config config.yaml --plan --liveApply deletions for specific buckets:
python -m aws_automations.s3_cleanup --config config.yaml --apply \
--bucket sandbox-a --bucket sandbox-bInteractive approval per bucket:
python -m aws_automations.s3_cleanup --config config.yaml --apply --interactiveJSON summary (suppresses live UI):
python -m aws_automations.s3_cleanup --config config.yaml --plan --jsonOne-off include/exclude without editing config:
python -m aws_automations.s3_cleanup --config config.yaml --include temp-bucket --exclude ignore-meToggle live rendering:
python -m aws_automations.s3_cleanup --config config.yaml --no-liveStart the interactive menu for guided cleanup:
aws-menuOr run directly:
python -m aws_automations.startClean up one or all services with a live table (default on TTY):
aws-cleanup --config config.yaml --service all --liveOr run via module:
python -m aws_automations.main --config config.yaml --service all --liveFocus on a single service (e.g., EC2) in dry-run:
python -m aws_automations.main --config config.yaml --service ec2Emit JSON summary (suppresses live UI):
python -m aws_automations.main --config config.yaml --service lambda --jsonSafety switches:
--force-zero-retentionrequired with--applywhenobject_retention_days <= 0--force-delete-allrequired with--applywhendelete_all_objects: true
Add --verbose for debug logs.
python -m pytestA practical sequence for using the tool without surprises:
# 1) inspect config
cat config.yaml
# 2) dry-run a single service
aws-cleanup --config config.yaml --service s3 --live
# 3) switch to JSON if you want machine-readable output
aws-cleanup --config config.yaml --service s3 --json
# 4) only then apply with explicit flags
aws-cleanup --config config.yaml --service s3 --applyQuick verification that install and CLI wiring are healthy:
python3 -m pip install --upgrade aws-automations
aws-cleanup --help
aws-menu --help
python3 -c "from importlib.metadata import version; print(version('aws-automations'))"- CI runs Bandit static security analysis on
aws_automations(Python 3.11 job). - Failing threshold is set to medium-or-higher severity/confidence.
bandit -r aws_automations --severity-level medium --confidence-level mediumSee CHANGELOG.md for versioned release notes.
- Uses paginated, batched deletes (S3 limits batches to 1,000 objects).
- Live UI is disabled automatically for JSON output or when stdout is not a TTY.
- Keep AWS credentials scoped to the buckets you intend to manage.