-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
57 lines (46 loc) · 1.27 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
resource "aws_s3_bucket" "my_bucket" {
bucket = var.bucket_name
tags = {
Name = var.bucket_tag_name
}
}
resource "aws_s3_bucket_public_access_block" "my_bucket_public_access" {
bucket = aws_s3_bucket.my_bucket.id
block_public_acls = false
block_public_policy = false
ignore_public_acls = false
restrict_public_buckets = false
}
resource "aws_s3_bucket_policy" "allow_get_object" {
bucket = aws_s3_bucket.my_bucket.id
policy = data.aws_iam_policy_document.allow_get_object_policy.json
}
data "aws_iam_policy_document" "allow_get_object_policy" {
statement {
sid = "AllowGetObject"
actions = ["s3:GetObject"]
resources = ["${aws_s3_bucket.my_bucket.arn}/*"]
principals {
type = "AWS"
identifiers = ["*"]
}
}
}
resource "aws_s3_object" "index_object" {
bucket = aws_s3_bucket.my_bucket.id
key = "index.html"
source = "index.html"
content_type = "text/html"
}
resource "aws_s3_bucket_versioning" "bucket_versioning" {
bucket = aws_s3_bucket.my_bucket.id
versioning_configuration {
status = "Enabled"
}
}
resource "aws_s3_bucket_website_configuration" "my_static_website" {
bucket = aws_s3_bucket.my_bucket.id
index_document {
suffix = "index.html"
}
}