Interview Prep/Python for DevOps/Data formats, HTTP & REST APIs

What is idempotency, and how do you design idempotent automation?

IntermediateConceptData formats, HTTP & REST APIs
Answer

An operation is idempotent if running it once or ten times leaves the system in the same state. It is what makes retries and re-runs safe.

  • Check-then-act on desired state: "ensure tag Owner=x exists", not "add tag".
  • Use APIs that are naturally idempotent (PUT, put_bucket_tagging, kubectl apply).
  • Pass client tokens: many AWS create calls accept ClientToken (run_instances, create_snapshot in some services) so a retried call does not create a second resource.
  • Treat "already exists" and "not found on delete" as success.
All Python for DevOps questions Roadmap: Python for automation

More on Data formats, HTTP & REST APIs