| 后端 | S3+DynamoDB 锁、GCS、Azure Storage、Terraform Cloud 等 |
|---|---|
| 敏感 | state 可能包含资源属性明文:访问控制与加密与密钥同级 |
| 团队 | 同一环境同一状态:避免多人各自 apply 覆盖 |
后端配置片段
后端配置片段
terraform {
backend "s3" {
bucket = "tfstate-prod"
key = "network/terraform.tfstate"
region = "cn-north-1"
dynamodb_table = "tf-locks"
encrypt = true
}
}状态丢失或损坏等于资源失联:开启版本化并定期演练恢复。