Staff Software Engineer on the @hbomax team @WarnerMedia and writer. Proud dad and husband. #ADHD and mental health in tech. He/him. Opinions are my own.
Moral of the story: idempotent code is good, therefore use existing tools where you can that have it built in, and only try and roll your own when you absolutely must.
Here's the good thing though: most good infrastructure-as-code tools have this built in! If you use Terraform, for example, and use it properly (I'm looking at you null resources), then it by-and-large ensures your code is idempotent without any effort from you.