The moved block that saved a destroy and recreate

Renaming a resource in the configuration is a destroy and a create as far as the plan is concerned, and on a database that is a very bad afternoon.

# the rename
moved {
  from = aws_db_instance.main
  to   = aws_db_instance.primary
}

# plan before: 1 to destroy, 1 to add
# plan after:  0 to change

# and for a resource moving into a module
moved {
  from = aws_s3_bucket.uploads
  to   = module.storage.aws_s3_bucket.uploads
}

The block is declarative and belongs in version control, which is the whole improvement over state mv — the rename is reviewable in the pull request that causes it, and it applies on every machine rather than on the one where somebody remembered to run the command. They can be removed after everybody has applied, and leaving them in place indefinitely costs nothing except clutter.