我有一个json文件,如下所示
{
"Domain": {
"Services": [{
"service1": [{
"custid" : "1104",
"fname" : "ton",
"lname" : "hatf",
}],
"service2": [{
"custid" : "1105",
"fname" : "ran",
"lname" : "ttt",
}],
"service3": [{
"custid" : "1106",
"fname" : "rin",
"lname" : "wqg",
}]
}]
}
}
我可以使用Terraform jsondecode()函数将json转换为如下所示的对象映射吗
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",
}
}
}
我试着用下面的代码读它
locals {
json_data = jsondecode(file("${path.module}/Domain.json"))
}
但不幸的是,我不知道如何使用它来构建上述地图(对象)