Nested loops for schedule and schedule_groups

Hi,

I'm create a terraform project to create a list of schedules and schedule groups using csv as the source data. The output ids of the schedule module feeds the input of the schedule_groups module. I created the basic logic in the code below:

What I'm trying to accomplish is to create a list of schedule ids that are to be assigned to a schedule-group.

The basic logic is here:

locals {

all-schedule-ids = {
"Australia_Day" = "49fa57ec-283d-4499-aa59-1a3c67303828"
"Boxing_Day" = "d36ccc3a-bd8c-425b-87d1-3f40606424da"
"Christmas_Day" = "cf983444-283c-4c1e-8513-1ecd40f1b86f"
"New_Years_Day" = "889fe41e-c957-4ecb-bb66-0c8f53810fcd"
"OPEN_24x7" = "c941592d-7b92-4a12-851d-b6034537be6e"
"SALES_800AM-7PM-M-F_Closed" = "290a8963-133a-4101-9090-48eab09f0426"
"SALES_800AM-7PM-M-F_Open" = "a69f6244-bb4a-4d1a-8c7a-f03941517071"
"SALES_900AM-5PM-S_Closed" = "0735f206-54f3-4874-8ca9-1e9f81e902e4"
"SALES_900AM-5PM-S_Open" = "cb9ec105-cbbc-476d-b1a0-31798f635403"
"SALES_EARLY_CLOSE" = "73c473c4-a777-4234-a542-fb8c83db328e"
"SERVICE_800AM-7PM-M-F_Open" = "730bb23d-aeb4-424e-907b-159a4542b21f"
"SERVICE_900AM-5PM-S_Closed" = "7b725b21-e492-419f-92f0-f7ecb3fca578"
"SERVICE_900AM-5PM-S_Open" = "3916c47f-d411-45ab-9c87-29dcc887eec5"
"SERVICE_EARLY_CLOSE" = "e919981c-5667-4ddc-83ba-64c4d395fb6e"

}

sg-sales-open = ["SALES_800AM-7PM-M-F_Open", "SALES_900AM-5PM-S_Open"]
sg-sales-closed = ["SALES_800AM-7PM-M-F_Closed"]
sg-sales-holiday = ["Christmas_Day", "Australia_Day"]

sg-service-open = ["SERVICE_900AM-5PM-S_Open", "SERVICE_800AM-7PM-M-F_Open"]
sg-service-closed = ["SERVICE_900AM-5PM-S_Closed"]
sg-service-holiday = ["Boxing_Day", "Australia_Day"]

schedule-ids-list1 = [ for k,v in local.all-schedule-ids : v if k == "OPEN_24x7" ]
schedule-ids-list2 = [ for k,v in local.all-schedule-ids : v if k == local.sg-sales-open[*]]
schedule-ids-list3 = [ for k,v in local.all-schedule-ids : v if k == ([ for x,y in local.sg-sales-open: y ]) ]
schedule-ids-list4 = [ v for k, v in local.all_schedule-ids if k in local.sg-sales-open ]
schedule-ids-map = [ for k,v in local.all-schedule-ids : v if k == [for day in local.sg-sales-open: day] ]

}

output "schedule-ids-list1" {
value = local.schedule-ids-list1
}

output "schedule-ids-list2" {
value = local.schedule-ids-list2
}

output "schedule-ids-list3" {
value = local.schedule-ids-list3
}

output "schedule-ids-list4" {
value = local.schedule-ids-list4
}

schedule-ids-list1 works fine
schedule-ids-list2,3 & 4 are variants that I've tried to loop through the schedule-ids and return the id value if the key in the map matches any value in the sg-sales-open list.
schedule-ids-map is incorrect syntax but contains the logic I'm looking for

Any ideas?

Output should look like this:
schedule-ids-list = ["a69f6244-bb4a-4d1a-8c7a-f03941517071","cb9ec105-cbbc-476d-b1a0-31798f635403"]