Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Sep 6, 2023
1 parent b7f6533 commit 6c50b37
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 28 deletions.
8 changes: 4 additions & 4 deletions cloudtrail/s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ resource "aws_s3_bucket_notification" "this" {
bucket = aws_s3_bucket.this.id

topic {
topic_arn = try(aws_sns_topic.cloudtrail_s3[0].arn, null)
events = ["s3:ObjectCreated:*"]
# filter_suffix = ".log"
topic_arn = try(aws_sns_topic.cloudtrail_s3[0].arn, null)
events = ["s3:ObjectCreated:*"]
filter_prefix = "cloudtrail/"
# filter_suffix = ".json.gz"
}
}

58 changes: 34 additions & 24 deletions cloudtrail/sns.s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,49 @@ resource "aws_sns_topic_policy" "cloudtrail_s3" {

data "aws_iam_policy_document" "cloudtrail_s3_topic" {
policy_id = format("%v_s3_topic", local.s3_name)
## statement {
## sid = "CloudtrailS3SNSPermissions"
## effect = "Allow"
## principals {
## type = "AWS"
## identifiers = ["*"]
## }
## actions = [
## "sns:Subscribe",
## "sns:SetTopicAttributes",
## "sns:RemovePermission",
## "sns:Receive",
## "sns:Publish",
## "sns:ListSubscriptionsByTopic",
## "sns:GetTopicAttributes",
## "sns:DeleteTopic",
## "sns:AddPermission",
## ]
## condition {
## test = "StringEquals"
## variable = "AWS:SourceOwner"
## values = [local.account_id]
## }
## resources = [var.enable_s3_sns ? aws_sns_topic.cloudtrail_s3[0].arn : ""]
## }
statement {
sid = "CloudtrailS3SNSPermissions"
sid = "CloudTrailSNSS3Policy"
effect = "Allow"
principals {
type = "AWS"
identifiers = ["*"]
type = "Service"
identifiers = ["s3.amazonaws.com"]
}
actions = [
"sns:Subscribe",
"sns:SetTopicAttributes",
"sns:RemovePermission",
"sns:Receive",
"sns:Publish",
"sns:ListSubscriptionsByTopic",
"sns:GetTopicAttributes",
"sns:DeleteTopic",
"sns:AddPermission",
]
actions = ["sns:Publish"]
resources = [var.enable_s3_sns ? aws_sns_topic.cloudtrail_s3[0].arn : ""]
condition {
test = "StringEquals"
variable = "AWS:SourceOwner"
values = [local.account_id]
}
resources = [var.enable_s3_sns ? aws_sns_topic.cloudtrail_s3[0].arn : ""]
}
statement {
sid = "CloudTrailSNSPolicy"
effect = "Allow"
principals {
type = "Service"
identifiers = ["cloudtrail.amazonaws.com"]
condition {
test = "ArnLike"
variable = "AWS:SourceArn"
values = [aws_s3_bucket.this.arn]
}
actions = ["sns:Publish"]
resources = [var.enable_s3_sns ? aws_sns_topic.cloudtrail_s3[0].arn : ""]
}
}

0 comments on commit 6c50b37

Please sign in to comment.