Skip to content

Instantly share code, notes, and snippets.

@0xkohe
Created June 25, 2020 04:56
Show Gist options
  • Save 0xkohe/1d6e4b92f7990002307589b3c4f8421d to your computer and use it in GitHub Desktop.
Save 0xkohe/1d6e4b92f7990002307589b3c4f8421d to your computer and use it in GitHub Desktop.
resource "aws_s3_bucket" "site" {
bucket = var.bucket_name
acl = "private"
tags = {
name = var.tag
}
force_destroy = true
versioning {
enabled = true
}
}
resource "aws_s3_bucket_policy" "site" {
bucket = aws_s3_bucket.site.id
policy = data.aws_iam_policy_document.s3_site_policy.json
}
data "aws_iam_policy_document" "s3_site_policy" {
statement {
actions = ["s3:GetObject"]
resources = ["${aws_s3_bucket.site.arn}/*"]
principals {
type = "AWS"
identifiers = [aws_cloudfront_origin_access_identity.site.iam_arn]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment