-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paths3.tf
More file actions
69 lines (56 loc) · 1.49 KB
/
s3.tf
File metadata and controls
69 lines (56 loc) · 1.49 KB
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
65
66
67
provider "aws" {
region = "us-east-1"
}
data "template_file" "empty_bucket_script" {
template = "${file("${path.module}/empty_bucket.tpl")}"
vars {
bucket_name = "${aws_s3_bucket.react_bucket.bucket}"
}
}
data "template_file" "populate_bucket_script" {
template = "${file("${path.module}/populate_bucket.tpl")}"
vars {
bucket_name = "${aws_s3_bucket.react_bucket.bucket}"
}
}
resource "null_resource" "create_local_empty_bucket_script" {
triggers {
template = "${data.template_file.empty_bucket_script.rendered}"
}
provisioner "local-exec" {
command = "echo \"${data.template_file.empty_bucket_script.rendered}\" > empty_bucket.sh; chmod +x empty_bucket.sh"
}
}
resource "null_resource" "create_local_populate_bucket_script" {
triggers {
template = "${data.template_file.populate_bucket_script.rendered}"
}
provisioner "local-exec" {
command = "echo \"${data.template_file.populate_bucket_script.rendered}\" > populate_bucket.sh; chmod +x populate_bucket.sh"
}
}
resource "aws_s3_bucket" "react_bucket" {
bucket = "${var.bucket_name}"
acl = "public-read"
policy = <<EOF
{
"Id": "bucket_policy_site",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "bucket_policy_site_main",
"Action": [
"s3:GetObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::${var.bucket_name}/*",
"Principal": "*"
}
]
}
EOF
website {
index_document = "index.html"
error_document = "index.html"
}
}