I have a json file as given below
{
"Domain": {
"Services": [{
"service1": [{
"custid" : "1104",
"fname" : "ton",
"lname" : "hatf",
}],
"service2": [{
"custid" : "1105",
"fname" : "ran",
"lname" : "ttt",
}],
"service3": [{
"custid" : "1106",
"fname" : "rin",
"lname" : "wqg",
}]
}]
}
}
Could I use Terraform jsondecode() function to convert the json to the map of objects as given below
variable "Services" {
type = map(object({
custid = string
fname = string
lname = string
}))
default = {
"service1" = {
custid = "1104",
fname = "ton",
lname = "hatf",
},
"service2" = {
custid = "1105",
fname = "ran",
lname = "ttt",
},
"service3" = {
custid = "1106",
fname = "rin",
lname = "wgg",
}
}
}
I tried to read it using the below code
locals {
json_data = jsondecode(file("${path.module}/Domain.json"))
}
But unfortunately I don't know how I could use it to build the above map(objects)