Undo a terraform apply by snapshotting state before each apply and restoring on demand.
How it works
Before every apply the extension runs terraform state pull and saves the state JSON to a local .tf-undo/ directory. On undo it pushes the saved state back with terraform state push -force and re-runs terraform apply so infrastructure is reconciled back to the pre-apply configuration.
Commands
Command
Description
Terraform: Apply (with Undo)
Snapshot state, then run terraform apply
Terraform: Undo Last Apply
Restore the most recent snapshot
Terraform: Plan
Run terraform plan
Terraform: Show Undo History
Open the sidebar history view
The sidebar tree view lists all snapshots with inline undo-to and delete buttons.
Settings
Setting
Default
Description
tf-undo.terraformPath
terraform
Path to terraform binary
tf-undo.maxSnapshots
20
Maximum snapshots to keep
tf-undo.autoApprove
false
Pass -auto-approve to apply
tf-undo.snapshotDir
.tf-undo
Directory for snapshots (relative to workspace)
tf-undo.confirmUndo
true
Confirm before undoing
Notes
Add .tf-undo/ to your .gitignore — state files can contain sensitive data.
The undo dialog offers Undo Apply (push state + apply) or Push State Only (state push only, then you can inspect with terraform plan before applying).
Snapshots are trimmed automatically to maxSnapshots.