Listing Resources within Terraform State
Explore how to use the terraform state list command to view resources within Terraform state files. Understand resource addressing syntax and when to interact directly with state using Terraform CLI subcommands.
What is a state in terraform?
The state maintained by Terraform is a JSON document stored locally or on a remote backend. Making direct edits to the file is highly discouraged. There are some occasions where we need to directly interact with the Terraform state, and in those cases, we use the terraform state command and its subcommands to assist us.
The terraform state subcommands
Below is a list of terraform state subcommands available for use.
- The
listsubcommand lists resources in the state. - The
mvsubcommand moves an item in the state. - The
pullsubcommand pulls the current state and output tostdout. - The
pushsubcommand updates the