An unattached disk does not know how long it has been unattached

2026-11-08来源 dev.to AWSEnglish

Yesterday I asked a Spanish-speaking dev subreddit how people find unattached disks and unused public IPs before the invoice does. That evening I published the commands I was using as a read-only bash script: cloud-orphans. It lists, it never deletes.

One reply asked about a grace period, so yesterday's detach does not get flagged. Answering it, I saw the gap in my script. An EBS volume has a CreateTime and no detach time, so my age_days counts from creation. You need your own first-seen-unattached tag, or the DetachVolume record in CloudTrail.

The other thing I explained there: on OCI a block volume reports AVAILABLE attached or not. You cross two lists, in every compartment, because the attachment lives with the instance:

oci bv volume list -c "$C" --all --query 'data[?"lifecycle-state"==`AVAILABLE`].id' oci compute volume-attachment list -c "$C" --all \ --query 'data[?"lifecycle-state"==`ATTACHED`]."volume-id"' 

How long do you wait before you call a disk an orphan?

I also build Control Cloud; the script stands on its own.

原文:https://www.a8q9.cn/en/article/an-unattached-disk-does-not-know-how-long-it-has-been-unattached-d11067.html

相关文章