Overview
When running Terraform locally, it stores the infrastructure state in a terraform.tfstate file within your working directory. However, you may also find a file with the same name, terraform.tfstate, located inside the .terraform directory.
It is important to understand that these two files serve different purposes. The file located at .terraform/terraform.tfstate is not the main state file for your configuration.
Purpose of the .terraform/terraform.tfstate File
Terraform creates the .terraform/terraform.tfstate file automatically when you configure a remote backend or the HCP Terraform cloud integration in your configuration.
This file's purpose is to store metadata about the backend connection itself. This can include workspace information and, for certain backends, cached access credentials. This file is used internally by Terraform to manage the connection to your remote state and is not interoperable with the primary terraform.tfstate file.