Commit 43e845eb authored by Anton Babenko's avatar Anton Babenko Committed by GitHub

fix: Always send `filter` map in replication config (#105)

parent 29de41cf
......@@ -58,7 +58,7 @@ module "s3_bucket" {
rules = [
{
id = "foo"
id = "something-with-kms-and-filter"
status = "Enabled"
priority = 10
......@@ -86,25 +86,45 @@ module "s3_bucket" {
}
},
{
id = "bar"
id = "something-with-filter"
status = "Enabled"
priority = 20
filter = {
prefix = "two"
tags = {
ReplicateMe = "Yes"
}
}
destination = {
bucket = "arn:aws:s3:::${local.destination_bucket_name}"
storage_class = "STANDARD"
}
},
{
id = "everything-with-filter"
status = "Enabled"
priority = 30
filter = {
prefix = "two"
tags = {
ReplicateMe = "Yes"
}
prefix = ""
}
destination = {
bucket = "arn:aws:s3:::${local.destination_bucket_name}"
storage_class = "STANDARD"
}
},
{
id = "everything-without-filters"
status = "Enabled"
destination = {
bucket = "arn:aws:s3:::${local.destination_bucket_name}"
storage_class = "STANDARD"
}
},
]
}
......
......@@ -172,8 +172,16 @@ resource "aws_s3_bucket" "this" {
}
}
# Send empty map if `filter` is an empty map or absent entirely
dynamic "filter" {
for_each = length(keys(lookup(rules.value, "filter", {}))) == 0 ? [] : [lookup(rules.value, "filter", {})]
for_each = length(keys(lookup(rules.value, "filter", {}))) == 0 ? [{}] : []
content {}
}
# Send `filter` if it is present and has at least one field
dynamic "filter" {
for_each = length(keys(lookup(rules.value, "filter", {}))) != 0 ? [lookup(rules.value, "filter", {})] : []
content {
prefix = lookup(filter.value, "prefix", null)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment