forked from hashicorp-education/learn-terraform-circleci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
67 lines (54 loc) · 1.32 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
56
57
58
59
60
61
62
63
64
65
66
67
provider "aws" {
region = var.region
default_tags {
tags = {
hashicorp-learn = "circleci"
}
}
}
resource "random_uuid" "randomid" {}
resource "aws_s3_bucket" "app" {
tags = {
Name = "App Bucket"
public_bucket = true
}
bucket = "${var.app}.${var.label}.${random_uuid.randomid.result}"
force_destroy = true
}
resource "aws_s3_bucket_ownership_controls" "app" {
bucket = aws_s3_bucket.app.id
rule {
object_ownership = "BucketOwnerPreferred"
}
}
resource "aws_s3_bucket_public_access_block" "app" {
bucket = aws_s3_bucket.app.id
block_public_acls = false
block_public_policy = false
ignore_public_acls = false
restrict_public_buckets = false
}
# resource "aws_s3_bucket_acl" "app" {
# depends_on = [
# aws_s3_bucket_ownership_controls.app,
# aws_s3_bucket_public_access_block.app,
# ]
# bucket = aws_s3_bucket.app.id
# acl = "public-read"
# }
resource "aws_s3_bucket_website_configuration" "app" {
bucket = aws_s3_bucket.app.bucket
index_document {
suffix = "index.html"
}
error_document {
key = "error.html"
}
}
resource "aws_s3_object" "app" {
# acl = "public-read"
key = "index.html"
bucket = aws_s3_bucket.app.id
content = file("./assets/index.html")
content_type = "text/html"
}