remote backend
What is remote backend?
remote backend: Stores state somewhere shared (S3, Terraform Cloud, GCS) so a team isn’t passing a local file around. A remote backend stores Terraform's state file in a shared, central place, such as an S3 bucket, Google Cloud Storage, Terraform Cloud or the HTTP backend of GitLab. Everyone on the team and the CI pipeline works with the same state.
Frequently asked questions about remote backend
How is remote backend used in practice?
With a local state file on one laptop, others cannot safely make changes, and losing that laptop can mean losing track of your infrastructure.
What should you keep in mind with remote backend?
Choose a backend that supports locking, so two people running apply at the same time cannot corrupt the state. Enable versioning on the storage, so you can recover from a bad change. Restrict access, because state files contain resource details and often secrets such as database passwords in plain text. Use separate state files per environment, so a mistake in staging cannot touch production.
What does an example of remote backend look like?
terraform { backend "s3" { bucket = "tf-state" key = "prod/app.tfstate" region = "eu-central-1" } } At a glance
| Category | Terraform |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |