Created
June 25, 2020 04:56
-
-
Save 0xkohe/1d6e4b92f7990002307589b3c4f8421d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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