-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy paths3_bucket.tf
53 lines (42 loc) · 1.17 KB
/
s3_bucket.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
# S3 bucket for web hosting
resource "aws_s3_bucket" "web_hosting_bucket" {
bucket = "${XXXX}-${data.aws_caller_identity.current.account_id}"
tags = {
Public = "Testing bucket as part of workshop content"
}
}
resource "aws_s3_bucket_public_access_block" "web_hosting_public_access_block" {
bucket = aws_s3_bucket.web_hosting_bucket.id
block_public_acls = false
block_public_policy = false
ignore_public_acls = false
restrict_public_buckets = false
}
resource "aws_s3_bucket_website_configuration" "web_hosting_website" {
bucket = aws_s3_bucket.web_hosting_bucket.id
index_document {
suffix = "XXXX"
}
error_document {
key = "XXXX"
}
}
# Bucket Policy
resource "aws_s3_bucket_policy" "web_hosting_policy" {
depends_on = [aws_s3_bucket_public_access_block.web_hosting_public_access_block]
bucket = aws_s3_bucket.web_hosting_bucket.id
policy = data.aws_iam_policy_document.web_hosting_policy.json
}
data "aws_iam_policy_document" "web_hosting_policy" {
statement {
principals {
type = "XXXX"
identifiers = ["*"]
}
actions = ["XXXX"]
resources = [
XXXX,
"XXXX/*"
]
}
}