-
Notifications
You must be signed in to change notification settings - Fork 12
/
terraform.tf
63 lines (51 loc) · 1.28 KB
/
terraform.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
terraform {
backend "s3" {
bucket = "sysadmin"
region = "us-east-1"
}
}
provider "aws" {
region = "us-east-1"
}
resource "random_pet" "bucket" {}
resource "aws_s3_bucket" "website_bucket" {
bucket = "p2pu-website-${random_pet.bucket.id}"
force_destroy = true
}
resource "aws_s3_bucket_public_access_block" "public_access_block" {
bucket = "p2pu-website-${random_pet.bucket.id}"
block_public_acls = false
block_public_policy = false
ignore_public_acls = false
restrict_public_buckets = false
}
resource "aws_s3_bucket_policy" "public_read" {
bucket = "p2pu-website-${random_pet.bucket.id}"
policy = data.aws_iam_policy_document.allow_public_access.json
}
data "aws_iam_policy_document" "allow_public_access" {
statement {
principals {
type = "*"
identifiers = ["*"]
}
actions = [
"s3:GetObject",
]
resources = [
"${aws_s3_bucket.website_bucket.arn}/*",
]
}
}
resource "aws_s3_bucket_website_configuration" "website" {
bucket = "p2pu-website-${random_pet.bucket.id}"
index_document {
suffix = "index.html"
}
}
output "site_url" {
value = aws_s3_bucket_website_configuration.website.website_endpoint
}
output "bucket" {
value = aws_s3_bucket_website_configuration.website.bucket
}