From the course: Developing Infrastructure as Code with Terraform

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Demo: Learning about Terraform state

Demo: Learning about Terraform state

- Okay, so I want to talk more about the Terraform state. It's a really critical piece of Terraform. So before we dive into the code examples and the Terraform syntax, I just want to make sure that you have an understanding of Terraform State. So again, it's a database, it's stored as a file. It tracks the resources that you've are managed by Terraform, it acts as the source of truth. So this is what allows Terraform to understand what it's already created, what it's managing, and what it expects the infrastructure to look like. The state requires special handling, right? So these are just some quick dos and don'ts when it comes to managing state. So do definitely store the state in a backend for any resources that you got deployed. It's important to store this in a backend. If the file, you know, if you're using a local state file and it gets deleted or corrupted, then Terraform no longer knows how to manage those resources, and you're going to have to go in and sort of manually…

Contents