Skip to content

Instantly share code, notes, and snippets.

@davidvpe
Created February 5, 2022 18:00
Show Gist options
  • Save davidvpe/f29424c30b3d0c7a9317b758bcfcb84d to your computer and use it in GitHub Desktop.
Save davidvpe/f29424c30b3d0c7a9317b758bcfcb84d to your computer and use it in GitHub Desktop.
data "aws_iam_policy_document" "s3_policy" {
statement {
actions = ["s3:GetObject"]
resources = ["${aws_s3_bucket.website.arn}/*"]
principals {
type = "AWS"
identifiers = [aws_cloudfront_origin_access_identity.oai.iam_arn]
}
}
}
resource "aws_s3_bucket_policy" "s3_policy" {
bucket = aws_s3_bucket.website.id
policy = data.aws_iam_policy_document.s3_policy.json
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment