Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
fiddling with bucket access permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerpen80 committed Apr 12, 2024
1 parent fe0abe5 commit 04b41b1
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions alarms_s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,28 @@ resource "aws_s3_bucket_policy" "alarm_bucket_policy" {
]
}

resource "aws_s3_bucket_acl" "bucket_access" {
bucket = aws_s3_bucket.alarm_bucket.id
acl = "private"
depends_on = [aws_s3_bucket_ownership_controls.this]
}

data "aws_iam_policy_document" "alarm_bucket_policy_doc" {
statement {
principals {
type = "AWS"
identifiers = ["*"]
}
actions = ["s3:GetObject","s3:PutBucketPolicy"]
actions = ["s3:GetObject"]
resources = [aws_s3_bucket.alarm_bucket.arn, "${aws_s3_bucket.alarm_bucket.arn}/*",]
}
statement {
principals {
type = "AWS"
identifiers = [data.aws_caller_identity.current.account_id]
}
actions = ["s3:PutBucketPolicy"]
resources = [aws_s3_bucket.alarm_bucket.arn, "${aws_s3_bucket.alarm_bucket.arn}/*",]

}
}

Expand All @@ -36,7 +49,7 @@ resource "aws_s3_bucket_public_access_block" "this" {
bucket = aws_s3_bucket.alarm_bucket.id

block_public_acls = true
block_public_policy = true
block_public_policy = false
ignore_public_acls = true
restrict_public_buckets = true
}
Expand Down

0 comments on commit 04b41b1

Please sign in to comment.