-
Notifications
You must be signed in to change notification settings - Fork 13
/
s3.tf
64 lines (48 loc) · 1.01 KB
/
s3.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
resource "aws_s3_bucket_policy" "main" {
bucket = aws_s3_bucket.main.id
policy = data.aws_iam_policy_document.bucket_policy.json
}
resource "aws_s3_bucket_acl" "main" {
bucket = aws_s3_bucket.main.id
acl = "private"
}
resource "aws_s3_bucket_website_configuration" "main" {
bucket = aws_s3_bucket.main.id
redirect_all_requests_to {
host_name = var.redirect_target
}
}
resource "aws_s3_bucket" "main" {
provider = aws.main
bucket = var.fqdn
force_destroy = var.force_destroy
tags = merge(
var.tags,
{
"Name" = var.fqdn
},
)
}
data "aws_iam_policy_document" "bucket_policy" {
provider = aws.main
statement {
sid = "AllowCFOriginAccess"
actions = [
"s3:GetObject",
]
resources = [
"arn:aws:s3:::${var.fqdn}/*",
]
condition {
test = "StringEquals"
variable = "aws:UserAgent"
values = [
var.refer_secret,
]
}
principals {
type = "*"
identifiers = ["*"]
}
}
}