-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy paths3.tf
47 lines (40 loc) · 940 Bytes
/
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
resource "random_string" "random" {
length = 16
special = false
min_lower = 16
}
resource "aws_s3_bucket" "website_bucket" {
bucket = "hello-cloudiac-${random_string.random.result}"
acl = "public-read"
force_destroy = true
website {
index_document = "index.html"
error_document = "index.html"
}
}
resource "aws_s3_bucket_policy" "website_bucket_policy" {
bucket = aws_s3_bucket.website_bucket.id
policy = <<POLICY
{
"Version": "2012-10-17",
"Id": "Public-Access",
"Statement": [
{
"Sid": "Allow-Public-Access-To-Bucket",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": [
"arn:aws:s3:::${aws_s3_bucket.website_bucket.bucket}/*"
]
}
]
}
POLICY
}
resource "aws_s3_bucket_object" "object" {
bucket = aws_s3_bucket.website_bucket.bucket
key = "index.html"
source = "index.html"
content_type = "text/html"
}