Hi guys, how are you?
I’m having difficulty developing logic with terraform functions.
I have a list of filters that I need to concatenate while the result is less than 100 characters.
locals {
# I have this data
data = [
"(host eq domain1.example.com and path eq /foo)",
"(host eq domain2.example.com and path eq /bar)",
"(host eq domain1.example.com and path eq /baz)",
]
# I need to concatenate the strings until the length is less than 100
invalid_data_more_chars = join(" or ", local.data)
# The expected output is
expected_output = [
"(host eq domain1.example.com and path eq /foo) or (host eq domain2.example.com and path eq /bar)",
"(host eq domain1.example.com and path eq /baz)",
]
}
I thought about making an accumulator and concatenating and testing the length() of the string, but I can’t do that inside a for.
Anyone have any ideas?