File tree 2 files changed +22
-13
lines changed
2 files changed +22
-13
lines changed Original file line number Diff line number Diff line change @@ -37,22 +37,25 @@ data "aws_iam_policy_document" "bucket_policy" {
37
37
# Deny access to bucket if it's not accessed through HTTPS
38
38
source_json = var. bucket_policy
39
39
40
- statement {
41
- sid = " EnforceTLS"
42
- actions = [" s3:GetObject" ]
43
- resources = [" arn:aws:s3:::${ local . bucket_name } /*" ]
40
+ dynamic statement {
41
+ for_each = var. require_tls ? [" enabled" ] : []
42
+ content {
43
+ sid = " EnforceTLS"
44
+ actions = [" s3:GetObject" ]
45
+ resources = [" arn:aws:s3:::${ local . bucket_name } /*" ]
44
46
45
- principals {
46
- type = " *"
47
- identifiers = [" *" ]
48
- }
47
+ principals {
48
+ type = " *"
49
+ identifiers = [" *" ]
50
+ }
49
51
50
- effect = " Deny"
52
+ effect = " Deny"
51
53
52
- condition {
53
- test = " Bool"
54
- variable = " aws:SecureTransport"
55
- values = [" false" ]
54
+ condition {
55
+ test = " Bool"
56
+ variable = " aws:SecureTransport"
57
+ values = [" false" ]
58
+ }
56
59
}
57
60
}
58
61
Original file line number Diff line number Diff line change @@ -50,3 +50,9 @@ variable "enable_versioning" {
50
50
description = " Keep old versions of objects in this bucket."
51
51
default = true
52
52
}
53
+
54
+ variable "require_tls" {
55
+ type = bool
56
+ description = " Require TLS to read objects from this bucket."
57
+ default = true
58
+ }
You can’t perform that action at this time.
0 commit comments