The best automation scripts are boring. You can run them twice and nothing bad happens.
When a script has to touch a lot of things, I follow the same rules every time:
- Dry run first. Every script has a mode that prints what it would do. I read that before anything real happens.
- Back up before changing. If a script edits a config, it saves the old one first. Undo should be one command.
- Make it re-runnable. Check before creating. If the thing already exists and looks right, skip it. A half-finished run can simply be run again.
- Go in stages. One target, then a few, then the rest. Check the results between stages.
- Run in parallel, but log everything. Speed is nice; knowing exactly what happened is better.
Python (with boto3) for anything with logic, Bash for glue, PowerShell when I'm on Windows. The language matters less than the habits.