A Terraform state file records the infrastructure managed by Terraform, including resource details and associated values. After the first terraform apply, Terraform creates terraform.tfstate beside the configuration files. section 7.8.7
Each later terraform apply loads the state, refreshes it from live infrastructure, and uses both sources to make changes efficiently. The state distinguishes infrastructure managed by this project from resources created by other projects or by manual means. section 7.8.7
Inspecting a state file
Run cat terraform.tfstate on Unix-like systems or type terraform.tfstate on Windows. A small state file can show a managed azurerm_resource_group, its provider, resource ID, location, name, and other attributes. section 7.8.7
Treat state as sensitive operational data. Requesting a sensitive Terraform output hides it in terminal output, but the value can still appear in plain text inside terraform.tfstate; automated deployment pipelines should remove local state when finished. section 7.9.4
Production workflows require deliberate state placement:
- Keep separate state for development, test, and production so updates affect the correct environment. section 12.2.6
- Store state in cloud storage such as Azure Storage and select it by environment name when Terraform runs in CI/CD. section 12.2.6
{
"version": 4,
"terraform_version": "1.5.6",
"serial": 1,
"lineage": "b10f693f-e27f-f223-a8ef-011948c56f9c",
"outputs": {},
"resources": [
{
"mode": "managed",
"type": "azurerm_resource_group",
"name": "flixtube",
"provider": "provider[\"registry.terraform.io/hashicorp/azurerm\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "/subscriptions/snip/resourceGroups/flixtube",
"location": "eastus",
"managed_by": "",
"name": "flixtube",
"tags": null,
"timeouts": null
},
"sensitive_attributes": [],
"private": snip"
}
]
}
],
"check_results": null
}
Browse a representative terraform.tfstate document to connect its JSON structure with managed resources and recorded attributes. section 7.8.7

