Looking for help parsing json output retrieved from an http data source. I have a data source defined as follows:
data "http" "admin_role" {
url = "https://api.datadoghq.com/api/v2/roles"
request_headers = {
Accept = "application/json",
DD-API-KEY = "xxx",
DD-APPLICATION-KEY = "xxx"
}
}
I then assign this value to an output so I can see what is coming back:
output "test_out_out" {
value = data.http.admin_role.body
}
My json looks like the following judging from my output value:
admin_role = jsonencode(
{
+ data = [
+ {
+ attributes = {
+ created_at = "2021-09-15T15:28:40.521369+00:00"
+ modified_at = "2021-09-15T15:28:40.521369+00:00"
+ name = "Datadog Admin Role"
+ user_count = 10
}
+ id = "yyyy-yyyy-yyyy-yyyy-yyyy"
+ relationships = {
+ permissions = {
+ data = [
+ {
+ id = "xxxxx-xxxx-xxxx-xxxx-xxxx"
+ type = "permissions"
},
…….
I’m trying to assign the id yyyy-yyyy-yyyy-yyyy-yyyy to a new variable, but no matter what I try I can’t seem to get it to work. Any help would be greatly appreciated!
Thanks!