Configuring a Terraform backend with state locking
In this section, we will explore how Terraform remote backends work and understand how state locking ensures the integrity and consistency of our infrastructure state when managing infrastructure deployments. Then, we will delve into the step-by-step process of configuring a remote backend to enable state locking.
Understanding Terraform remote backends
Up until this point, we have used the default local backend, which stores the state as a local file (that is, the terraform.tfstate
file). This type of setup should be okay when only a single engineer is involved. Once another engineer wants to apply configuration changes to the same set of resources with Terraform, using a remote backend will make more sense since the second engineer needs to have access to the existing state file (used by the first engineer). In addition to this, we need to make sure that configuration changes to the same set of resources are not applied at...