Hi @joeminicucci,
why are you using double $$ in your local example?
Apart from that, I don’t get your question. Are you trying to prepare the records section ?
Do you have examples of the data structures?
The double $$ interpolation was a leftover of me trying to find a cause as to why the local was not working. The problem is that when I in-line the string manipulation it works, but with locals is does not. The intention is to use a single local rather than sprinkling this large line of code throughout the module.
The data it would be trying to manipulate is any domain string, example would be example.google.com and the manipulation should yield the TLD as google.com
I don’t think count.index is available within locals.
So any values in var.domain-mappings have to be processed before and then within the module call you could use it like local.tld[count.index]. However there’s a dependency on the order between both “variables” so it might be better to use a map.
locals{
tld = [ for k in var.domain-mappings : join(".",tolist([reverse(split(".", k ))[1],reverse(split(".",k ))[0]])) ]
}
While referencing tld[count.index] and var.domain-mappings[count.index] in the module call, it’s assumed that the order is the same in both lists.
Therefore a single map for both lists might be better.