Skill 6.3.1
Configuring a backend block
Key Concepts
For example, terraform { backend "s3" { bucket = "acme-tfstate" key = "network/terraform.tfstate" region = "eu-west-1" use_lockfile = true } } stores state in an S3 bucket with native locking. Each backend type has its own arguments; common built-in types are s3, azurerm, gcs, consul, pg, kubernetes, http and remote. A configuration can have only one backend.
Backend blocks are processed before anything else, so their arguments cannot use variables, locals or data sources. Remote backends give shared access, locking, encryption and, with S3 versioning, recovery of previous state versions. HCP Terraform is connected with a separate cloud block rather than a backend block.