Hi,
I am trying to loop through multiple list to get the resource created for each entity and I run into error as “String required”
Below is my YAML file
---
process:
- process_name: proc1
process_id: 1
clusters:
linux_clusters:
- list:
- p1
- p2
runtime: containerd
- list:
- p3
- p4
runtime: docker
windows_clusters:
- list:
- p1
- p2
runtime: containerd
My resource definition looks like below with for_each looping
locals {
process_yamls = fileset(path.module, "./process/*/*.yaml")
processes = flatten([ for yaml in local.process_yamls : yamldecode(file(yaml))["process"] ])
linux_cluster_list = try(flatten(local.processes[0].clusters.linux_clusters.*),[])
}
resource "process_groups" "group" {
for_each = {for cluster in local.linux_cluster_list : cluster.list => cluster }
cluster_name = each.value
type = "kubernetes"
runtime_type = each.value.runtime
}
Is there a way to address this or restructuring the YAML is the option ?
Thanks