What does a hardened S3 state bucket look like?
IntermediateProductionState and Backends in Production
Answer
Versioning on, default SSE-KMS encryption, all four public-access-block settings enabled, a bucket policy that denies non-TLS requests and restricts principals to the CI roles, access logging, lifecycle rules to expire noncurrent versions after N days, and optionally cross-region replication.
resource "aws_s3_bucket_versioning" "state" {
bucket = aws_s3_bucket.state.id
versioning_configuration { status = "Enabled" }
}
More on State and Backends in Production
Why should Terraform state never be committed to Git?BeginnerHow do you bootstrap the remote backend, given the bucket must exist before Terraform can use it?IntermediateWhat is the minimum IAM permission set for the S3 backend?IntermediateHow do you move from DynamoDB locking to S3 native locking in a live fleet?IntermediateState was deleted or corrupted. How do you recover?AdvancedHow do you split a monolithic state and what drives blast-radius decisions?Advanced