I have the following variable
api_access = {
"test" = {
role_names = [
"Role1"
"Role2
]
}
}
I need to iterate trough each element of the list, where I perform a lookup for the string to the the appropriate id. So I do this
locals {
role_ids = {
for app, ids in var.api_access : app => {
for roleid in ids.role_names : "role_ids" => [
//getroleid() which results in e.g. "00000000-0000-0000-0000-000000000001"
]...
}
}
}
So far the above gives me
+ role_ids = {
+ "test" = {
+ "role_ids" = [
+ [
+ "00000000-0000-0000-0000-000000000001",
],
+ [
+ "00000000-0000-0000-0000-000000000002",
],
]
}
}
I would get this:
+ role_ids = {
+ "test" = {
+ "role_ids" = [
+ [
+ "00000000-0000-0000-0000-000000000001",
+ "00000000-0000-0000-0000-000000000000",
],
]
}
}
I tried to flatten
the role_ids
as follows
for roleid in ids.role_names : "role_ids" =>flatten([
roleid
]...)
Which fails with
Call to function “flatten” failed: can only flatten lists, sets and tuples.