Kanji
・Cloud engineer / freelance ・Born in 1993 ・From Ehime / Living in Shibuya, Tokyo ・5 years AWS experience Profile details
Table of Contents
In a versioning-enabled general purpose bucket, deleting an object without a version ID makes a delete marker current. The key disappears from an ordinary listing ( ListObjectsV2 ) while older data versions can still incur storage charges. Before changing retention, I count the data versions and markers for that exact key. AWS guide to managing delete markers
ListObjectsV2
This read-only procedure needs the AWS CLI, jq and s3:ListBucketVersions on the test bucket. Set BUCKET and KEY to the test bucket name and the complete object key. The API --prefix parameter can also match neighboring keys (such as a and a.b ), so the filter checks exact equality ( .Key == $k ) after retrieval. Leave CLI pagination enabled to count every page.
jq
s3:ListBucketVersions
BUCKET
KEY
--prefix
a
a.b
.Key == $k
aws s3api list-object-versions --bucket "${BUCKET:?}" --prefix "${KEY:?}" --output json | jq --arg k "$KEY" '{ versions: ([.Versions[]? | select(.Key == $k)] | length), markers: ([.DeleteMarkers[]? | select(.Key == $k)] | length), latest_marker: any(.DeleteMarkers[]?; .Key == $k and .IsLatest) }'
Check that the AWS CLI succeeded. AccessDenied or empty stdout does not establish a zero count.
AccessDenied
To preserve recovery versions, the following rule fragment targets only a sole remaining marker under sandbox/ . Review it alongside the bucket’s existing rules. This action does not support a tag filter. AWS Lifecycle configuration examples
sandbox/
{ "ID": "clean-sole-marker", "Status": "Enabled", "Filter": {"Prefix": "sandbox/"}, "Expiration": {"ExpiredObjectDeleteMarker": true} }
ExpiredObjectDeleteMarker: true
versions == 0
markers == 1
Tag
Prefix
Days
Date
Expiration
NoncurrentVersionExpiration
NoncurrentDays
To reclaim older data, evaluate NoncurrentVersionExpiration separately. Its age clock starts when a version becomes noncurrent. Permanent expiration removes that recovery point. Existing qualifying versions also fall within scope. Lifecycle processing is asynchronous, so revisit the same key before diagnosing a delay as a rule failure. AWS expiration semantics
I ran the jq filter against synthetic JSON containing data keys a and a.b and a current marker for a . Selecting a returned versions=1 , markers=1 and latest_marker=true . An empty object returned 0 , 0 and false . I also checked the decision predicate in Python. For (data versions, markers) of (1,1) , (0,1) , (0,2) and (1,0) , the expression v == 0 and m == 1 returned [False, True, False, False] . AWS deletion latency and charges were not measured. Unverified in production.
versions=1
markers=1
latest_marker=true
0
false
(data versions, markers)
(1,1)
(0,1)
(0,2)
(1,0)
v == 0 and m == 1
[False, True, False, False]
Real-time AI quant analysis of earnings reports, corporate filings, and momentum indicators for global equities and Japanese stocks.
Master conversation skills with realistic AI phone training and 5-axis feedback. Includes 16-lesson interactive academy and studio AI portraits.
Effortlessly snap receipts for instant AI itemization. Integrated with LINE for seamless group expense tracking and pain-free settlement.
Interactive AI personas (Fortune Teller, Butler, Bartender) host real-time games, challenges, and conversation starters for unforgettable gatherings.
Unbiased healthcare database featuring zero-additive filters and active ingredient cost performance metrics.