12. Terraform State File
The Terraform state file is a JSON-formatted file that stores the current state of your infrastructure, including all the resources that Terraform has created and their associated metadata. The state file acts as the interface between Terraform and the actual infrastructure, allowing Terraform to keep track of the resources it manages and understand how to update or destroy them.
In other words, the Terraform state file is like Terraform's memory or record of the infrastructure you've created.
You might have noticed a new file named terraform.tfstate created during your first terraform apply
. This is the state file.