Skip to content

Commit

Permalink
Add Object Ownership to enable ACLs for redirect bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbuckley committed Oct 13, 2023
1 parent ef0bb01 commit 0bdf8fc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions modules/aws/route53/aliases.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@ resource "aws_s3_bucket" "redirect" {
bucket = each.key
}

resource "aws_s3_bucket_acl" "redirect" {
resource "aws_s3_bucket_ownership_controls" "redirect" {
for_each = toset(concat(var.aliases, [for a in var.aliases : "www.${a}"]))
bucket = aws_s3_bucket.redirect[each.key].bucket
acl = "private"
rule {
object_ownership = "ObjectWriter"
}
}

resource "aws_s3_bucket_acl" "redirect" {
for_each = toset(concat(var.aliases, [for a in var.aliases : "www.${a}"]))
depends_on = [aws_s3_bucket_ownership_controls.redirect]
bucket = aws_s3_bucket.redirect[each.key].bucket
acl = "private"
}

resource "aws_s3_bucket_website_configuration" "redirect" {
Expand Down

0 comments on commit 0bdf8fc

Please sign in to comment.