-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorage.tf
39 lines (35 loc) · 944 Bytes
/
storage.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
resource "aws_s3_bucket" "website" {
bucket = "${local.root_fqdn}"
website = {
index_document = "${var.index_document}"
error_document = "${var.error_document}"
}
tags = {
Terraform = 1
Scope = "${data.aws_route53_zone.zone.name}"
}
}
resource "aws_s3_bucket_policy" "website" {
bucket = "${aws_s3_bucket.website.id}"
policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PrimaryCloudFrontGetObject",
"Effect": "Allow",
"Principal": {"AWS": ["${aws_cloudfront_origin_access_identity.identity.iam_arn}"]},
"Action": "s3:GetObject",
"Resource": "${aws_s3_bucket.website.arn}/*"
},
{
"Sid": "PrimaryCloudFrontListBucket",
"Effect": "Allow",
"Principal": {"AWS": ["${aws_cloudfront_origin_access_identity.identity.iam_arn}"]},
"Action": "s3:ListBucket",
"Resource": "${aws_s3_bucket.website.arn}"
}
]
}
POLICY
}