What does terraform plan do?
Options
- It applies the changes immediately to the real infrastructure
- It compares config and state and shows what would change (Correct option)
- It deletes the state file so that the next run starts from clean
- It formats the code files so that they match the Terraform style
Answer
Compares desired config with state and real infrastructure, and shows what would change without changing anything
Why
Terraform describes infrastructure (servers, databases, networks) as code. That is Infrastructure as Code.
terraform plan is a dry run: it compares your code with what exists and lists what it WOULD create, change or destroy. Nothing changes yet.
After reviewing, terraform apply makes the changes. The state file maps code to real resources; keep it in shared remote storage with locking.
Remember
plan = preview. apply = do it.