Interview Prep/Python for DevOps/AWS automation with boto3

You are writing a cleanup Lambda that deletes unattached EBS volumes. How do you avoid deleting something important?

IntermediateScenarioAWS automation with boto3
Answer

Situation read → "Unattached" (State=available) does not mean "unwanted".

What I'd do →

  1. Filter status=available, then require a minimum age since detachment (CloudTrail DetachVolume time or a detached-at tag set by a first pass).
  2. Skip volumes tagged Retain=true or owned by a known system.
  3. Snapshot before deletion (tag the snapshot with source volume and date) for a recovery window.
  4. Run in report mode for two weeks before enabling deletion.

Why → A two-phase "mark, then sweep" design gives owners time to object.

Interview tip → "Mark and sweep with a grace period" is the pattern name to use.

All Python for DevOps questions Roadmap: Python for automation

More on AWS automation with boto3