Hi
Is it possible to use a nested loop in templating like the one below? I currently have the first loop working correctly, but I’m encountering a problem with the nested one, it inserts 2 rows, when I’m expecting only one
locals {
prom_jobs = ["job1", "job2"]
sd_configs = ["config_1.json", "config_2.json"]
}
%{ if try(prom_jobs, []) != [] ~}
%{for prom_job in prom_jobs ~}
- job_name: ${prom_job)
%{for config_file in sd_configs ~}
file_sd_condifgs:
- ${config_file)
%{ endfor ~}
basic_auth:
username: 'foo'
password: 'bar'
%{ endfor ~}
%{ endif ~}
Here is Templated output. I’m expecting to have one config file per job, instead, it gives me 2
- job_name: job1
file_sd_configs:
- config_1.json
- config_2.json <-- shouldn't be here
basic_auth:
username: foo
password: bar
- job_name: job2
file_sd_configs:
- config_1.json <-- shouldn't be here
- config_2.json
basic_auth:
username: foo
password: bar