Skip to content

Commit

Permalink
Add bucket policy to allow public access
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkcuys committed Mar 26, 2024
1 parent e21bd9e commit ae4d065
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ resource "aws_s3_bucket_public_access_block" "public_access_block" {
restrict_public_buckets = false
}

resource "aws_s3_bucket_policy" "public_read" {
bucket = "p2pu-website-${random_pet.bucket.id}"
policy = data.aws_iam_policy_document.allow_public_access.json
}

data "aws_iam_policy_document" "allow_public_access" {
statement {
principals {
type = "*"
identifiers = ["*"]
}

actions = [
"s3:GetObject",
]

resources = [
"${random_pet.bucket.arn}/*",
]
}
}

resource "aws_s3_bucket_website_configuration" "website" {
bucket = "p2pu-website-${random_pet.bucket.id}"

Expand Down

0 comments on commit ae4d065

Please sign in to comment.