Terraform manages and tracks the state of infrastructure resources through a file known as
terraform.tfstate. This file is automatically created by Terraform and is updated after the application
of a Terraform plan to capture the current state of the resources.
State File Purpose: The terraform.tfstate file contains a JSON object that records the IDs and
properties of resources Terraform manages, so that it can map real-world resources to your
configuration, keep track of metadata, and improve performance for large infrastructures.
State File Management: This file is crucial for Terraform to perform resource updates, deletions, and
for creating dependencies. It's essentially the 'source of truth' for Terraform about your managed
infrastructure and services.
Reference: This behavior is documented in Terraform's official documentation, which explains how
the terraform.tfstate file is used to keep track of the infrastructure Terraform is managing.