-
Notifications
You must be signed in to change notification settings - Fork 0
/
local.tf
34 lines (34 loc) · 1.45 KB
/
local.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
locals {
# Constants
total_buckets = var.bucket.replicas + 1
source_bucket_arns = [
"arn:aws:s3:::${var.bucket.name}",
"arn:aws:s3:::${var.bucket.name}/*"
]
destination_bucket_arns = [
for i in range(1, local.total_buckets):
"arn:aws:s3:::${var.bucket.name}-replica-0${i}"
]
destination_bucket_path_arns = [
for i in range(1, local.total_buckets):
"arn:aws:s3:::${var.bucket.name}-replica-0${i}/*"
]
event_notification_id = "${var.bucket.name}-notifications"
event_notification_arn = "arn:aws:sns:*:*:${local.event_notification_id}"
# Calculations
conditions = {
merge_policies = var.bucket.policy != null
provision_key = var.bucket.key == null
}
# Configurations
encryption_configuration = local.conditions.provision_key ? (
module.key[0].key
) : (
var.bucket.key
)
policy_configuration = local.conditions.merge_policies ? (
data.aws_iam_policy_document.merged
) : (
data.aws_iam_policy_document.unmerged
)
}