I have following json
{
"applications": [
{"abc": {"app": "myapp", "org": "myorg_a"}},
{"bcd": {"app": "myapp2", "org": "myorg_b"}}
]
}
I need org = "myorg_a" in harness provider block https://registry.terraform.io/providers/harness/harness/latest/docs
#Configure the Harness provider for Next Gen resources
provider "harness" {
endpoint = "https://app.harness.io/gateway"
account_id = myorg_a
platform_api_key = "mike"
}
I need to read myorg_a dynamically since tomorrow json may change to myorg_c. I need help to achieve it.
Using (data.http.myapi.body).applications.abc.org I can read myorg_a but can't hardcode abc.
When I tried (data.http.myapi.body).applications[0]["org"] I get error "The given key does not identify an element in this collection value. An object only supports looking up attributes by name, not by numeric index."
I created this proposal using local variable and flattened that object using a nested iteration.
output for testing