Skip to content

Commit

Permalink
s3-ssl-policy (#295)
Browse files Browse the repository at this point in the history
* fluentd

* lint
  • Loading branch information
Ng Tze Yang authored Oct 27, 2023
1 parent 8b3db22 commit 67c81b8
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions modules/fluentd/s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,39 @@ resource "aws_s3_bucket" "logs" {
}
}

data "aws_iam_policy_document" "s3_logs_policy" {
count = var.logs_s3_enabled ? 1 : 0
statement {
sid = "AllowSSLRequestsOnly"
actions = ["s3:*"]
effect = "Deny"

resources = [
aws_s3_bucket.logs[0].arn,
"${aws_s3_bucket.logs[0].arn}/*",
]

condition {
test = "Bool"
variable = "aws:SecureTransport"
values = [false]
}

principals {
type = "*"
identifiers = ["*"]
}
}
}

resource "aws_s3_bucket_policy" "logs" {
count = var.logs_s3_enabled ? 1 : 0

bucket = aws_s3_bucket.logs[0].id

policy = data.aws_iam_policy_document.s3_logs_policy[0].json
}

data "aws_iam_policy_document" "logs_s3" {
count = var.logs_s3_enabled ? 1 : 0

Expand Down

0 comments on commit 67c81b8

Please sign in to comment.