When i want to pass a list of map to a Terraform variable(where i use dynamic block to iterate over this list) i get this error:
│ Cannot use a string value in for_each. An iterable collection is required.
My list of maps in my variable group in Azure Devops:
{ "host" = "mysite1.com", "name" = "healthprobe1", "path" = "/healthcheck1" },
{ "host" = "mysite2.com", "name" = "healthprobe2", "path" = "/healthcheck2" },
{ "host" = "mysite2.com", "name" = "healthprobe3", "path" = "/healthcheck3" }
My variable in variable group:
My Terraform configuration which iterate over a list of maps:
The variable:
variable "PROBES" {
default = [{}]
}
The dynamic block:
dynamic "probe" {
for_each = var.PROBES
content {
host = probe.value.host
interval = 30
minimum_servers = 0
name = probe.value.name
path = probe.value.path
pick_host_name_from_backend_http_settings = false
protocol = local.protocol
timeout = 30
unhealthy_threshold = 3
match {
status_code = ["200-399"]
}
}
}