terraform state surgery without losing a finger
Every terraform codebase eventually needs refactoring. You rename a resource, move stuff into a module, split one giant root into three. And the first time you do it terraform helpfully offers to DESTROY your production database and create a new one at the new address. Fun. Here's the order I do things in now. Mostly learned by almost doing it wrong. 0. back up the state. every time. terraform state pull >…