Interview Prep/Terraform/State Internals

How do you migrate state from one backend to another safely?

AdvancedConceptState Internals
Answer
  1. Back up: terraform state pull > backup.tfstate.
  2. Edit the backend block to the new one.
  3. Run terraform init -migrate-state and confirm the copy.
  4. Run terraform plan and expect no changes.
  5. Keep the old state read-only for a while before deleting it. Make sure nobody applies during the migration.
All Terraform questions Roadmap: Terraform in production

More on State Internals