Interview Prep/Python for DevOps/Automation scripting & CLI design

Your script must process 50,000 S3 keys and must be resumable if it crashes midway. How do you design it?

AdvancedScenarioAutomation scripting & CLI design
Answer

Situation read → Long-running batch, partial failure is likely, reprocessing must be safe.

What I'd do →

  1. Make per-item work idempotent (re-copying or re-tagging the same object is harmless).
  2. Record progress durably: a checkpoint file written atomically every N items with the last processed key (S3 lists keys in lexicographic order, so StartAfter=last_key resumes the listing), or a DynamoDB/SQLite table of done keys.
  3. Handle SIGTERM: finish the current item, write the checkpoint, exit.
  4. Collect failures in a separate file for retry instead of aborting the run.
  5. For bigger jobs, use S3 Batch Operations or fan out via SQS workers.

Why → Checkpoint plus idempotency means a crash costs minutes, not a full rerun.

Interview tip → Mention StartAfter; it shows you know how S3 listing works.

All Python for DevOps questions Roadmap: Python for automation

More on Automation scripting & CLI design