How to manage Terraform state

This is Part 3 of the Comprehensive Guide to Terraform series. In Part 1, you learned why we picked Terraform as our IAC tool of choice and not Chef, Puppet, Ansible, Pulumi, or CloudFormation. In Part 2, you got started with the basic syntax and features of Terraform and used them to deploy a cluster of web servers on AWS. In this post, you’ll learn about how Terraform manages state and the impact that has on file layout, isolation, and locking in a Terraform project.

Here are the topics we’ll cover:

  1. What is Terraform state?
  2. Shared storage for state files
  3. Limitations with Terraform’s Backends
  4. Isolating state files
  5. The terraform_remote_state data source

You can find working sample code for the examples in this blog post in the Terraform: Up & Running code samples repo. This blog post corresponds to Chapter 3 of Terraform Up & Running, “How to Manage Terraform State,” so look for the code samples in the 03-terraform-state folders.

Learn More