I would like to get a index based values in the resource block values Current setup:
locals{
Vvn = {
"0" = "sam1"
"1" = " sam2"
"3" = "sam3"
}
I need to get this vvn values sam1, sam2, sam3 based on index keys in the below resource block.
resource "null_resource"
"sample" {
for_each = var.sampleconfig
name = each.value.flag==true? { for n in range(length(local.vvn)): local.vvn[n]] : "string.each.value.name"
}
}
But it throws error and cannot able to get index based value .I don't want to pass local variables vvn to for_each since already iam using another map. I just tried out index, lookup functions but no luck. Expected output :
In resource block I want touse name value index based values of locals.vvn each by each. Any help appreciated.
Thanks.
To get value of a map based on index, you can use
values. For example,But this returns values based on exicographical order order, not based on keys.
To use your keys, you can: