State surgery without the CLI: import, moved and removed blocks with for_each
For about eight years, changing what is in the state meant typing terraform state mv and terraform import by hand,
one resource at a time, in the right order, hoping nobody else ran an apply in between. Those commands still exist, but
you should mostly stop using them. There are three declarative blocks - import, moved, removed - that do the same
thing from code, show up in the plan, go through code review, and since they accept for_each they handle fifty
resources as easily as one. This is in both OpenTofu and Terraform (since 1.7 on both sides), so unlike my last two
posts this is not a “Tofu only” trick - it is a “most people still don’t use it” trick.