Hi all
I’m trying to create a map in order to create resource using for_each. Values are gathered from .yaml files like:
escalations_merged = [for i in fileset(local.configuration_path, "/oncalls//*-oncall.yaml") : yamldecode(file(“{local.configuration_path}/{i}”))[“escalation”]]
The escalation yaml is a section containing the following:
escalation:
- step:
order: 1
type: “wait”
duration: “300”
escalation_chain: “test-service2-team” - step:
order: 2
type: “wait”
duration: “600”
escalation_chain: "test-service2-team
The aim here is to gather all escalation declarations from yaml files, combine them and create in resource for the ‘wait’ function.
I’ve tried:
escaluations_wait_map = flatten([for f, file in local.escalations_merged :[for v, val in file :
{
position = val[“order”]
type = val[“type”]
duration = val[“duration”]
escalation_chain = val[“escalation_chain”]
}
if val[“type”] == “wait”
]])
In the for_each however, it is not working:
for_each = { for x in local.oncalls_map : “{x.escalation_chain}-{x.position}” => x }
│
│ This object does not have an attribute named …
Any suggestions would be much appreciated.