Safe Terraform Refactoring with Moved Blocks and Module Composition
Refactor monolithic Terraform configs into modules while keeping production resources intact using moved blocks.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Refactor monolithic Terraform configs into modules while keeping production resources intact using moved blocks.
Migrate Terraform resource addresses safely with the 1.1+ <code>moved</code> block. Learn how it works, see a step‑by‑step example, and avoid common pitfalls for a smooth refactor.
Goal: use Terraform moved block to rename a resource while also updating its arguments (e.g., tags) without triggering a delete‑create replace that could cause downtime. Constraint: the moved block guarantees a move action only when the resource type and provider stay the same and no ID‑changing arguments are modified; however, Terraform’s documentation does