-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths3.tf
64 lines (59 loc) · 1.24 KB
/
s3.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
resource "aws_s3_bucket" "hugo" {
bucket = "${var.project_name}-intermediate"
acl = "private"
}
// For the www domain, redirects to the root domain.
resource "aws_s3_bucket" "hugo_final" {
bucket = "${var.www_domain_name}"
acl = "public-read"
policy = <<EOF
{
"Version":"2012-10-17",
"Statement":[
{
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::${var.www_domain_name}/*"
]
}
]
}
EOF
website {
redirect_all_requests_to = "https://${var.root_domain_name}"
}
}
// For the root domain
resource "aws_s3_bucket" "hugo_root" {
bucket = "${var.root_domain_name}"
acl = "public-read"
policy = <<POLICY
{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Principal": "*",
"Action":[
"s3:GetObject"
],
"Resource":[
"arn:aws:s3:::${var.root_domain_name}/*"
]
}
]
}
POLICY
website {
// Here we tell S3 what to use when a request comes in to the root
// ex. https://www.runatlantis.io
index_document = "index.html"
// The page to serve up if a request results in an error or a non-existing
// page.
error_document = "404.html"
}
}