Skip to content

Commit

Permalink
Enable bucket acl
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Galeano Galeano committed Oct 18, 2023
1 parent f79b021 commit db071c4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bucket_notification.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ resource "aws_s3_bucket_notification" "bucket_notification" {
events = var.notifications_events
}
}
}
}
38 changes: 38 additions & 0 deletions kms_encription.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@ data "aws_iam_policy_document" "primary" {
}
}
}

dynamic "statement" {
for_each = var.notifications_sns ? [1] : []
content {
sid = "Allow access for Key User (S3 Service Principal)"
effect = "Allow"
resources = [aws_kms_key.primary[0].arn]

actions = [
"kms:GenerateDataKey*",
"kms:Decrypt",
]

principals {
type = "Service"
identifiers = ["s3.amazonaws.com"]
}
}
}
}

data "aws_iam_policy_document" "secondary" {
Expand Down Expand Up @@ -133,6 +152,25 @@ data "aws_iam_policy_document" "secondary" {
}
}

dynamic "statement" {
for_each = var.notifications_sns ? [1] : []
content {
sid = "Allow access for Key User (S3 Service Principal)"
effect = "Allow"
resources = [aws_kms_key.primary[0].arn]

actions = [
"kms:GenerateDataKey*",
"kms:Decrypt",
]

principals {
type = "Service"
identifiers = ["s3.amazonaws.com"]
}
}
}


}

Expand Down
9 changes: 9 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ resource "aws_s3_bucket_acl" "default" {
provider = aws.primary
bucket = aws_s3_bucket.default.id
acl = var.acl

depends_on = [aws_s3_bucket_ownership_controls.default]
}

resource "aws_s3_bucket_ownership_controls" "default" {

Check failure on line 31 in main.tf

View workflow job for this annotation

GitHub Actions / checkov-action

CKV2_AWS_65: "Ensure access control lists for S3 buckets are disabled"
bucket = aws_s3_bucket.default.id
rule {
object_ownership = "BucketOwnerPreferred"
}
}

resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
Expand Down

0 comments on commit db071c4

Please sign in to comment.