Bucket Version Cleanup (GCP)
CostLens flags Cloud Storage buckets with object versioning enabled but no lifecycle rule to delete noncurrent versions, so old versions accumulate storage indefinitely.
CostLens flags versioned Cloud Storage buckets with no cleanup rule. With object versioning on and no lifecycle rule to remove noncurrent versions, every overwrite and delete keeps the previous version forever. A rule that deletes noncurrent versions after N days (or keeps only the latest few) reclaims that storage.
How it works
Buckets are enumerated
CostLens lists buckets via the Cloud Storage JSON API and checks each one's versioning setting and lifecycle rules.
Uncleaned versioned buckets are flagged
Buckets with versioning enabled but no Delete rule conditioned on numNewerVersions or noncurrent objects are surfaced.
Savings are estimated
Sized via the Cloud Monitoring storage/total_bytes gauge, priced as a conservative fraction (~15%) of storage attributable to accumulated noncurrent versions.
What to do
- Add a lifecycle rule that deletes noncurrent versions after N days (e.g. 30), and/or keeps only the most recent few (
numNewerVersions). - Consider whether the bucket needs versioning at all — if not, disabling it stops new versions accumulating.
Severity levels
| Severity | Estimated monthly savings |
|---|---|
| critical | >$500 |
| high | $100–$500 |
| medium | $20–$100 |
| low | <$20 |
Required permissions
- Detect: Storage read + Monitoring Viewer (beyond the default GCP Accounts roles — same as Bucket Lifecycle Policy). Without them this check produces nothing and never blocks the rest of your analysis.
Limitations
- The savings figure is an estimate — actual overhead depends on how often objects are overwritten/deleted.
- Buckets below the size threshold, or with a noncurrent-version cleanup rule already present, are not flagged.