# The concept

### Resource Tracking

* A way for Terraform to keep tabs on what has been deployed&#x20;
* Critical to terraform functionality

<figure><img src="https://1722711354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwNXdoUkfmcozr29fRrfb%2Fuploads%2Fob0p8hQcDszSVaJishcJ%2Fimage.png?alt=media&#x26;token=0112c793-38f7-455c-bfb9-500c162670e4" alt=""><figcaption></figcaption></figure>

### Terraform State

* Simply put, it maps real-world resources to Terraform configuration
* Stored in flat files, by default name "terraform.tfstate"
* Help terraform calculate deployment data and create new deployment plan
* Prior to any modification operation, Terraform refresh the state file.
* Resource dependency metadata is also tracked in the state file
* Help boost deployment performance by caching resource attributes if subsequent use
* Never lose the Terraform state file!

### Terraform State Command

* Terraform state command is a utility for manipulating and reading the Terraform state file.
* Scenario:
  * Advance state management
  * Manually remove a resource from Terraform state file so that it's not managed by Terraform
  * Listing out tracked resources and their detail (via state and list subcommands)

<figure><img src="https://1722711354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwNXdoUkfmcozr29fRrfb%2Fuploads%2F8TutzomyUOXuqkIpDUlf%2Fimage.png?alt=media&#x26;token=014d198a-f7c7-4001-9007-b67951b04978" alt=""><figcaption></figcaption></figure>

