What does terraform plan do and why should you always review it before applying?
terraform plan creates an execution plan — a preview of what Terraform will do before it actually makes changes. It shows additions, modifications, and destructions.
Always review the plan because:
- It may show unexpected destructions (e.g., a stateful database being replaced instead of modified)
- It catches misconfiguration before real infrastructure is affected
- In a CI/CD pipeline, save the plan output and apply that exact plan in the next step to ensure consistency
terraform plan -out=tfplan
terraform apply tfplan