Getting Familiar with the Terraform State File

Learn about the format of a Terraform state file and how to modify it.

Overview

Previously, we learned how important the Terraform state file is and how it’s a true reflection of our existing infrastructure. We’ll further explore a state file and how it outlines our resources as well as the interconnection between the resources. Terraform equally provides us a CLI tool, the terraform state command, to be able to work with the state file instead of modifying the file manually.

Terraform state file example

Let’s consider the example where we created a VPC and a subnet on AWS. The generated state file terraform.tfstate will look as follows:

Get hands-on with 1200+ tech skills courses.