If you can help me a nested dynamic group I am trying to solve, I have the values coming from a json like below
{
"avi_gslbservice_groups": [
{
"name": "us-east-1",
"priority": 10,
"algorithm": "GSLB_ALGORITHM_ROUND_ROBIN",
"avi_gslbservice_groups_ip": {
"host": "url2",
"enabled": "false"
}
},
{
"name": "us-east-2",
"priority": 7,
"algorithm": "GSLB_ALGORITHM_TOPOLOGY",
"avi_gslbservice_groups_ip": {
"host": "url1",
"enabled": "false"
}
}
]
}
and dynamic code snippet like this,
dynamic "groups" {
for_each = var.avi_gslbservice_groups
content {
dynamic "members" {
for_each = groups.value.avi_gslbservice_groups_ip
content {
ip {
type = "V4"
addr = ""
}
fqdn = members.value["host"]
vs_uuid = ""
cluster_uuid = ""
ratio = 1
enabled = members.value["enabled"]
}
}
name = groups.value["name"]
priority = groups.value["priority"]
algorithm = groups.value["algorithm"]
}
}
problem I am facing is, name, priority and algorithm all get picked up correctly, but I am not able to select fqdn (host value from json) and enabled (enabled from json) from the second layer in json
Error message I get at terraform plan is,
Error: Invalid index
on modules\avi\avi_gslbservice.tf line 25, in resource "avi_gslbservice" "avi_gslbservice":
25: fqdn = members.value["host"]
├────────────────
│ members.value is "false"
This value does not have any indices.
Error: Invalid index
on modules\avi\avi_gslbservice.tf line 25, in resource "avi_gslbservice" "avi_gslbservice":
25: fqdn = members.value["host"]
├────────────────
│ members.value is "url2"
This value does not have any indices.
Error: Invalid index
on modules\avi\avi_gslbservice.tf line 25, in resource "avi_gslbservice" "avi_gslbservice":
25: fqdn = members.value["host"]
├────────────────
│ members.value is "false"
This value does not have any indices.
Error: Invalid index
on modules\avi\avi_gslbservice.tf line 25, in resource "avi_gslbservice" "avi_gslbservice":
25: fqdn = members.value["host"]
├────────────────
│ members.value is "url1"
This value does not have any indices.
Error: Invalid index
on modules\avi\avi_gslbservice.tf line 29, in resource "avi_gslbservice" "avi_gslbservice":
29: enabled = members.value["enabled"]
├────────────────
│ members.value is "false"
This value does not have any indices.
Error: Invalid index
on modules\avi\avi_gslbservice.tf line 29, in resource "avi_gslbservice" "avi_gslbservice":
29: enabled = members.value["enabled"]
├────────────────
│ members.value is "url2"
This value does not have any indices.
Error: Invalid index
on modules\avi\avi_gslbservice.tf line 29, in resource "avi_gslbservice" "avi_gslbservice":
29: enabled = members.value["enabled"]
├────────────────
│ members.value is "false"
This value does not have any indices.
Error: Invalid index
on modules\avi\avi_gslbservice.tf line 29, in resource "avi_gslbservice" "avi_gslbservice":
29: enabled = members.value["enabled"]
├────────────────
│ members.value is "url1"
This value does not have any indices.