Question 1 · choose 1
A developer is finished with a temporary environment and wants to see exactly what would be removed before removing everything the configuration manages. Which commands do this?
- Aterraform graph to preview, then terraform fmt
- Bterraform validate -destroy to preview, then terraform apply
- Cterraform show to preview, then delete terraform.tfstate
- Dterraform plan -destroy to preview, then terraform destroy
Show the answer and why
Aterraform graph to preview, then terraform fmt
Incorrect
graph shows dependencies and fmt rewrites files; neither removes anything.
Bterraform validate -destroy to preview, then terraform apply
Incorrect
validate has no destroy mode, and apply without -destroy keeps the resources.
Cterraform show to preview, then delete terraform.tfstate
Incorrect
Deleting state leaves every object running and unmanaged.
Dterraform plan -destroy to preview, then terraform destroy
Correct
plan -destroy shows a speculative destroy plan, and terraform destroy is an alias for apply -destroy that prompts before acting.
Destroy is just a planning mode: preview with plan -destroy, run it with destroy (or apply -destroy).
HashiCorp documentation
- terraform graph command (DOT output of the dependency graph) (opens in a new tab)
- terraform fmt command (check mode and other options) (opens in a new tab)
- terraform validate command (syntax and consistency, no remote services) (opens in a new tab)
- terraform apply command (automatic plan mode and saved plan mode) (opens in a new tab)
- terraform show command (state or a saved plan file) (opens in a new tab)
- State overview (what state is) (opens in a new tab)
- terraform destroy command (alias for apply -destroy, plan -destroy preview) (opens in a new tab)
- terraform plan command (planning modes and options) (opens in a new tab)