Remote State

Learn how to work with a remote state in Terraform projects.

Local state vs. remote state

As stated at the start of this chapter, the default storage for a Terraform state is in a local file called terraform.tfstate. This is fine when working on a local project or for small proof of concepts, but it does not practically scale beyond that. If you want to work on a Terraform project on more than one machine or with more than one person, then the local state won’t cut it anymore.

The reason local state storage isn’t practical is that (as we have learned in this chapter) Terraform uses its state file to store a record of what it has created. If you run Terraform from one machine and create a number of resources then run the same project from another machine, Terraform will try to create all of those resources again on the second machine as the second machine will not have a state file. This means that the second run ...