The concept

Resource Tracking

  • A way for Terraform to keep tabs on what has been deployed

  • Critical to terraform functionality

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)

Last updated