11# Main state bucket
22resource "aws_s3_bucket" "tfstate_bucket" {
3+ # checkov:skip=CKV_AWS_144: We don't want to replicate outside our region
4+ # checkov:skip=CKV2_AWS_62: We won't enable event notifications for this bucket, yet
35 bucket = " ${ var . project_name } -${ var . environment } -tfstate"
46 tags = {
57 Stack = " Bootstrap"
@@ -95,6 +97,9 @@ resource "aws_s3_bucket_lifecycle_configuration" "tfstate_bucket" {
9597# Logging
9698
9799resource "aws_s3_bucket" "tfstate_s3_access_logs" {
100+ # checkov:skip=CKV_AWS_144: We don't want to replicate outside our region
101+ # checkov:skip=CKV2_AWS_62: We won't enable event notifications for this bucket, yet
102+ # checkov:skip=CKV_AWS_21: Versioning not needed given short lifecycle of logs
98103 bucket = " ${ var . project_name } -${ var . environment } -tfstate-access-logs"
99104}
100105
@@ -109,7 +114,8 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "tfstate_s3_access
109114
110115 rule {
111116 apply_server_side_encryption_by_default {
112- sse_algorithm = " AES256"
117+ sse_algorithm = " aws:kms"
118+ kms_master_key_id = aws_kms_key. terraform_state_bucket_cmk . arn
113119 }
114120 }
115121}
@@ -131,6 +137,16 @@ resource "aws_s3_bucket_lifecycle_configuration" "tfstate_s3_access_logs_object_
131137 noncurrent_days = var. log_retention_in_days
132138 }
133139 }
140+ rule {
141+ id = " StateBucketLogsMultipartUploadExpiration"
142+ status = " Enabled"
143+ filter {
144+ prefix = " "
145+ }
146+ abort_incomplete_multipart_upload {
147+ days_after_initiation = 7
148+ }
149+ }
134150}
135151
136152resource "aws_s3_bucket_public_access_block" "s3logs" {
0 commit comments