Remote Backends#
Every team beyond a single developer needs remote state. The three major backends:
S3 + DynamoDB (AWS):
terraform {
backend "s3" {
bucket = "myorg-tfstate"
key = "prod/network/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-locks"
encrypt = true
}
}Azure Blob Storage:
terraform {
backend "azurerm" {
resource_group_name = "tfstate-rg"
storage_account_name = "myorgtfstate"
container_name = "tfstate"
key = "prod/network/terraform.tfstate"
}
}Google Cloud Storage:
terraform {
backend "gcs" {
bucket = "myorg-tfstate"
prefix = "prod/network"
}
}All three support locking natively (DynamoDB for S3, blob leases for Azure, object locking for GCS). Always enable encryption at rest and restrict access with IAM.