-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
55 lines (46 loc) · 1.05 KB
/
main.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
terraform {
required_version = ">= 0.12.7"
}
locals {
environment_name = terraform.workspace
index_html_file = "${terraform.workspace}.index.html"
}
provider "aws" {
version = "~> 2.0"
region = "us-east-1"
}
resource "aws_s3_bucket" "website_bucket" {
bucket = "${local.environment_name}.feature.environment.blog.com"
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
}
output "website_endpoint" {
value = aws_s3_bucket.website_bucket.website_endpoint
}
output "s3_bucket_name" {
value = aws_s3_bucket.website_bucket.id
}