Skip to main content
Athena writes the results of every query to an S3 bucket, and keeps them there forever unless a lifecycle rule removes them. Results are rarely read again after a few days. nOps finds Athena result buckets that keep growing with nothing deleted, and estimates the saving from expiring results older than 30 days.

Why it matters

Busy Athena users and dashboards write new results every day, so the results bucket grows steadily and is billed every month.

How nOps finds it

nOps reads 90 days of S3 Standard storage for buckets named like Athena query-results buckets, in accounts that ran Athena queries in the last 30 days. A bucket is flagged when it grew by at least 5% over 90 days, never shrank by more than 3% on any day, and had no other storage class or lifecycle transition in the last 14 days. Everything stored 30 days ago is treated as results at least 30 days old, and must be at least 1 GB. The saving is that share of the bucket’s Standard storage cost, at your billed rate, and must be at least $5 a month.

Before you start

Permission to update lifecycle rules (s3:GetLifecycleConfiguration, s3:PutLifecycleConfiguration).

How to implement

  1. Confirm the bucket only holds query results, and that no CTAS or UNLOAD output you need to keep is written there.
  2. Save the current lifecycle rules: aws s3api get-bucket-lifecycle-configuration --bucket BUCKET.
  3. Add a rule that expires objects after 30 days, scoped to the results prefix if the bucket holds anything else, and keep every existing rule (S3 → bucket → Management → Create lifecycle rule → Expire current versions of objects).
  4. If versioning is on, also expire noncurrent versions, or the old results stay billed.
  5. Update Terraform or CloudFormation with the same rule.

Risks and considerations

  • Expired results are deleted permanently unless versioning is on.
  • Athena query result reuse looks back a limited time, so results older than 30 days are rarely reused.
  • The bucket is identified by its name, so check its contents before adding the rule.
  • To roll back, remove the rule. Objects already expired cannot be recovered.