S3 Noncurrent Version Cleanup
CostLens flags version-enabled S3 buckets with no rule to expire old object versions — noncurrent versions accumulate and often dwarf the live data.
When versioning is enabled, every overwrite and delete silently retains the previous version forever unless a lifecycle rule expires it. Noncurrent versions frequently end up costing more than the live objects. CostLens flags versioned buckets that have no noncurrent-version expiry rule.
How it works
CostLens lists your buckets
Calls s3:ListAllMyBuckets and resolves each bucket's region.
Checks versioning + lifecycle
Reads GetBucketVersioning; for versioning-enabled buckets it looks for a NoncurrentVersionExpiration lifecycle rule.
Flags buckets without expiry
Flags versioned buckets above a minimum size with no noncurrent-version expiry rule, estimating the retained-version storage.
What to do
- Open the recommendation to see the bucket and estimated savings.
- Apply the fix — CostLens adds a
NoncurrentVersionExpirationrule (default: expire noncurrent versions after a retention window). - Confirm the retention window suits your recovery needs before applying.
Check your recovery window first
Expiring old versions is appropriate when you don't need long-term version history. If you rely on noncurrent versions for recovery or compliance, choose a longer retention period.
Severity levels
| Severity | Estimated monthly savings |
|---|---|
| critical | >$500 |
| high | $100–$500 |
| medium | $20–$100 |
| low | <$20 |
Required IAM permissions
Detection uses ReadOnlyAccess; the fix adds lifecycle write — included in the CostLens policies from AWS Accounts:
s3:ListAllMyBuckets
s3:GetBucketVersioning
s3:GetBucketLifecycleConfiguration
s3:PutLifecycleConfiguration
Limitations
- Retained-version storage is estimated; actual savings depend on how much version history exists.
- Buckets with versioning suspended/disabled and those below the size threshold are skipped.