# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huy312100.gitbook.io/software-development/devops/iac/terraform/terraform-state/the-concept.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
