-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths3-bucket-inventory.tf
49 lines (38 loc) · 1.38 KB
/
s3-bucket-inventory.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
resource "aws_s3_bucket_inventory" "inventories" {
for_each = var.inventory_config
bucket = aws_s3_bucket.bucket.id
name = each.key
included_object_versions = each.value.include_noncurrent_objects ? "All" : "Current"
schedule {
frequency = each.value.frequency
}
destination {
bucket {
account_id = each.value.destination != null ? each.value.destination.account_id : null
bucket_arn = each.value.destination != null ? (each.value.destination.bucket_arn != null ? each.value.destination.bucket_arn : aws_s3_bucket.bucket.arn) : aws_s3_bucket.bucket.arn
format = each.value.output_format
dynamic "encryption" {
for_each = each.value.encrypt_inventory_report != null ? [1] : []
content {
dynamic "sse_kms" {
for_each = each.value.encrypt_inventory_report.kms_key_id != null ? [1] : []
content {
key_id = each.value.encrypt_inventory_report.kms_key_id
}
}
dynamic "sse_s3" {
for_each = each.value.encrypt_inventory_report.kms_key_id != null ? [] : [1]
content {}
}
}
}
}
}
dynamic "filter" {
for_each = each.value.filter != null ? [1] : []
content {
prefix = each.value.filter.prefix
}
}
optional_fields = each.value.additional_metadata_fields
}