I would like to loop over a list and generate different template files based on each item in that list .
type locals {
project_name = "${var.project}"
my_list = ["allowed-users","denied-users"]
}
resource "null_resource" "run_my_template" {
for_each = toset(local.my_list)
provisioner "local-exec" {
interpreter = ["bash", "-c"]
command = "my-cli create -f $FILE"
environment = { FILE = templatefile("${path.module}/artifacts/template/${each.value}.tftpl", { project_name = local.project_name , action_from_my_list = ${each.value} } ) }
}
}
using each.value is not accepted and returns:
This character is not used within the language.
and
Expected the start of an expression, but found an invalid expression token.
how can I create a list of template using the templatefile function or other based on a provided list of item ?
thanks