File tree Expand file tree Collapse file tree
infrastructure/modules/s3 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,14 +105,57 @@ data "aws_iam_policy_document" "access_logs_s3_bucket_policy" {
105105 variable = " aws:SecureTransport"
106106 }
107107 }
108+
109+ # Allow S3 Log Delivery service to write access logs
110+ statement {
111+ sid = " S3ServerAccessLogsPolicy"
112+ effect = " Allow"
113+ principals {
114+ type = " Service"
115+ identifiers = [" logging.s3.amazonaws.com" ]
116+ }
117+ actions = [
118+ " s3:PutObject"
119+ ]
120+ resources = [
121+ " ${ aws_s3_bucket . storage_bucket_access_logs . arn } /*"
122+ ]
123+ condition {
124+ test = " ArnEquals"
125+ variable = " aws:SourceArn"
126+ values = [aws_s3_bucket . storage_bucket . arn ]
127+ }
128+ }
129+
130+ # Allow S3 Log Delivery service to check bucket location and get bucket ACL
131+ statement {
132+ sid = " S3ServerAccessLogsDeliveryRootAccess"
133+ effect = " Allow"
134+ principals {
135+ type = " Service"
136+ identifiers = [" logging.s3.amazonaws.com" ]
137+ }
138+ actions = [
139+ " s3:GetBucketAcl" ,
140+ " s3:ListBucket"
141+ ]
142+ resources = [
143+ aws_s3_bucket . storage_bucket_access_logs . arn
144+ ]
145+ condition {
146+ test = " ArnEquals"
147+ variable = " aws:SourceArn"
148+ values = [aws_s3_bucket . storage_bucket . arn ]
149+ }
150+ }
108151}
109152
110153resource "aws_s3_bucket_server_side_encryption_configuration" "storage_bucket_access_logs_server_side_encryption_config" {
111154 bucket = aws_s3_bucket. storage_bucket_access_logs . id
112155
113156 rule {
114157 apply_server_side_encryption_by_default {
115- sse_algorithm = " aws:kms"
158+ sse_algorithm = " aws:kms"
116159 kms_master_key_id = aws_kms_key. storage_bucket_cmk . arn
117160 }
118161 }
You can’t perform that action at this time.
0 commit comments