You are building automation for infrastructure provisioning and service deployment, and you know the same workflow may be retried after partial failure, timeout, or operator interruption. You want the automation to produce the same end state whether it runs once or multiple times, without creating duplicate resources or leaving systems in an inconsistent state.
Describe your approach to writing idempotent automation code.