InTouch Hub · Blue Isle Software

S3 Cleanup

Delete S3 objects older than N days from a bucket prefix. Configurable retention; dry-run mode prints what would be deleted without removing. Daily summary of bytes freed.

s3-cleanup

Delete S3 objects older than N days from a bucket prefix. Daily summary of bytes freed. Dry-run mode for the first few runs so you can preview without accidentally nuking anything.

Use case

S3 buckets accumulate. Build artifacts, log dumps, temp files, expired exports — they sit there forever and quietly cost money. S3 Lifecycle Policies handle this in theory, but they're a pain to author for one-off cases and they apply silently with no notification. This workflow runs daily, deletes by age, and emails you a one-line summary so you know it ran and what it cleaned.

This is a YAML workflow, not a skill — pure plumbing, no AI value.

Setup

  1. Create an aws credential with s3:ListBucket, s3:DeleteObject, and s3:GetObject on the target bucket
  2. Edit workflow.yaml: - BUCKET — your bucket name (no s3:// prefix) - PREFIX — path inside the bucket (trailing slash matters; empty string = whole bucket) - RETENTION_DAYS — anything older than this gets deleted - DRY_RUN1 for first runs (preview only), then flip to 0 once you trust it
  3. Schedule daily (or weekly for low-churn buckets)

Pipeline

  1. cleanupruntimeenv (bash + AWS CLI) — lists, filters by LastModified, deletes (or previews)
  2. notifymessage — sends the summary

Safety notes

Customization

Source

See workflow.yaml.