I have the following structure
workers =
[
{
auto_scaling.min = "1"
auto_scaling.max = "6"
auto_scaling.desired = "1"
labels = {
namespace = "default"
role = "testing"
}
}
]
As you can see, I have an array of maps with two nested maps inside. The first being auto_scaling. After some googling I found the . trick such that I could do ${lookup(var.workers[count.index], "auto_scaling.min")} to return the value vs trying to do two lookups which doesn't work as lookup only works with flat items.
However, that above trick doesn't work for the labels component because I need to be able to access the map as a whole to pass it to jsonencode. I have tried various things but haven't found a solution yet so wondering if anyone else out there can think outside the box and come up with a solution.
The above variable is actually used to spin up different Auto-Scaling groups and the labels are then passed into as user data such that during provisioning the node can be labled with those labels (kubernetes nodes).
Thanks