What are advanced Terraform state management operations?

Answer

Advanced state management operations for production scenarios: terraform state mv: rename a resource in state without destroying it — used when refactoring module structure or renaming resources. terraform state mv module.old.aws_instance.web module.new.aws_instance.web. terraform state rm: remove a resource from state without destroying the actual infrastructure — used when you want to stop managing a resource with Terraform. terraform state pull/push: download or upload state JSON directly — for manual state surgery (last resort). terraform state replace-provider: replace the provider source in state after provider namespace changes. State migration: move state between backends by changing the backend config and running terraform init -migrate-state. Partial state corruption recovery: use state versioning (S3 versioning enabled on the state bucket) to restore a previous state version. Always back up state before any manual state operations.