Does Terraform have rollback? How do you undo a bad change?
AdvancedScenarioTesting Upgrades and Large-Scale Operations
Answer
Situation read → A change made things worse.
What I'd do →
- Revert the commit and apply (roll forward with the old code).
- For replaced resources, recreate from the previous config; stateful data comes from backups.
- If state is wrong, restore the previous state version from S3 versioning, then plan.
Why → Terraform has no transactional rollback; "revert in Git and apply" works for stateless resources only.
Interview tip → Distinguish stateless (easy) from stateful (needs backups).
More on Testing Upgrades and Large-Scale Operations
What does each of `terraform validate`, `plan` and `terraform test` actually check?BeginnerWrite a native test for a module that creates an encrypted S3 bucket.IntermediateCompare Terratest with `terraform test`.IntermediateReal-cloud integration tests leave orphaned resources when they fail midway. How do you handle that?AdvancedHow do you upgrade from Terraform 1.5 to 1.9 safely?IntermediateMajor AWS provider upgrade from v4 to v5 (or v5 to v6) across many stacks. How do you plan it?Advanced