terraform statefile

how does terraform know what changes to make?

  • it stores the current state of the infra in a file called the terraform.tfstate
  • this file contains all the metadata about the resources in the infra
  • tf uses this file to directly compare what changes it must do to make current state = desired state

Note: when we run terraform plan it creates this file and stores in our PC! it is not the best thing to do, and it is always better to store it in a remote backend!

202604162222