File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,24 @@ resource "aws_s3_bucket_acl" "this" {
27
27
acl = " private"
28
28
}
29
29
30
+ resource "aws_s3_bucket_ownership_controls" "this" {
31
+ bucket = aws_s3_bucket. this . id
32
+
33
+ rule {
34
+ object_ownership = " BucketOwnerEnforced"
35
+ }
36
+ }
37
+
38
+ resource "aws_s3_bucket_server_side_encryption_configuration" "this" {
39
+ bucket = aws_s3_bucket. this . bucket
40
+
41
+ rule {
42
+ apply_server_side_encryption_by_default {
43
+ sse_algorithm = " AES256"
44
+ }
45
+ }
46
+ }
47
+
30
48
resource "aws_s3_bucket_website_configuration" "this" {
31
49
bucket = aws_s3_bucket. this . id
32
50
@@ -62,6 +80,40 @@ data "aws_iam_policy_document" "s3_this" {
62
80
]
63
81
}
64
82
}
83
+ statement {
84
+ sid = " DenyIncorrectEncryptionHeader"
85
+ effect = " Deny"
86
+ actions = [" s3:PutObject" ]
87
+ resources = [" ${ aws_s3_bucket . this . arn } /*" ]
88
+ principals {
89
+ type = " AWS"
90
+ identifiers = [
91
+ " *" ,
92
+ ]
93
+ }
94
+ condition {
95
+ test = " StringNotEquals"
96
+ variable = " s3:x-amz-server-side-encryption"
97
+ values = [" AES256" ]
98
+ }
99
+ }
100
+ statement {
101
+ sid = " DenyUnEncryptedObjectUploads"
102
+ effect = " Deny"
103
+ actions = [" s3:PutObject" ]
104
+ resources = [" ${ aws_s3_bucket . this . arn } /*" ]
105
+ principals {
106
+ type = " AWS"
107
+ identifiers = [
108
+ " *" ,
109
+ ]
110
+ }
111
+ condition {
112
+ test = " Null"
113
+ variable = " s3:x-amz-server-side-encryption"
114
+ values = [" true" ]
115
+ }
116
+ }
65
117
}
66
118
67
119
resource "aws_s3_bucket_policy" "this" {
You can’t perform that action at this time.
0 commit comments