generated from pbs/terraform-aws-template-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
106 lines (105 loc) · 2.99 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
data "aws_iam_policy_document" "bucket_policy_doc" {
count = var.bucket_policy == null ? 1 : 0
dynamic "statement" {
for_each = var.allow_anonymous_vpce_access ? [var.allow_anonymous_vpce_access] : []
content {
actions = [
"s3:GetObject",
]
resources = ["arn:aws:s3:::${local.name}/*"]
condition {
test = "StringEquals"
variable = "aws:sourceVpce"
values = [var.vpce]
}
principals {
type = "*"
identifiers = ["*"]
}
}
}
dynamic "statement" {
for_each = local.create_replication_target_policy ? [local.create_replication_target_policy] : []
content {
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${var.replication_source.account_id}:role/${var.replication_source.role}"]
}
actions = [
"s3:ReplicateDelete",
"s3:ReplicateObject",
]
resources = ["arn:aws:s3:::${local.name}/*"]
}
}
dynamic "statement" {
for_each = local.create_replication_target_policy ? [local.create_replication_target_policy] : []
content {
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${var.replication_source.account_id}:role/${var.replication_source.role}"]
}
actions = [
"s3:List*",
"s3:GetBucketVersioning",
"s3:PutBucketVersioning"
]
resources = ["arn:aws:s3:::${local.name}"]
}
}
dynamic "statement" {
for_each = local.create_replication_target_policy ? [local.create_replication_target_policy] : []
content {
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${var.replication_source.account_id}:role/${var.replication_source.role}"]
}
actions = [
"s3:ObjectOwnerOverrideToBucketOwner"
]
resources = ["arn:aws:s3:::${local.name}/*"]
}
}
dynamic "statement" {
for_each = var.force_tls ? [var.force_tls] : []
content {
effect = "Deny"
principals {
type = "*"
identifiers = ["*"]
}
actions = ["s3:*"]
resources = [
"arn:aws:s3:::${local.name}",
"arn:aws:s3:::${local.name}/*",
]
condition {
test = "Bool"
variable = "aws:SecureTransport"
values = ["false"]
}
}
}
dynamic "statement" {
for_each = var.cloudfront_oac_access_statements
content {
actions = ["s3:GetObject"]
resources = ["arn:aws:s3:::${local.name}/${statement.value.path}"]
principals {
type = "Service"
identifiers = ["cloudfront.amazonaws.com"]
}
condition {
test = "StringEquals"
variable = "aws:SourceArn"
values = [statement.value.cloudfront_arn]
}
}
}
source_policy_documents = var.source_policy_documents
override_policy_documents = var.override_policy_documents
}
resource "aws_s3_bucket_policy" "bucket_policy" {
bucket = local.name
policy = local.bucket_policy
}