【发布时间】:2022-01-25 16:21:12
【问题描述】:
我有以下对象列表:
variable "accounts" {
default =[{
hub = "54326543266"
ou_name = "test1"
spoke = "76547654765"
vpc_cidr = "10.13.0.0/16"
},
{
hub = "54326543266"
ou_name = "test1"
spoke = "563904425760"
vpc_cidr = "10.14.0.0/16"
},
{
hub = "54387632457"
ou_name = "test2"
spoke = "934960631748"
vpc_cidr = "10.13.0.0/16"
},
{
hub = "54387632457"
ou_name = "test2"
spoke = "43892321454"
vpc_cidr = "10.14.0.0/16"
}
]
我想获取一个对象列表,将具有相同hub 和ou_name 的对象合并为以下格式:
[{
hub = "54326543266"
ou_name = "test1"
spokes = [
{ spoke = "76547654765", vpc_cidr = "10.13.0.0/16" },
{ spoke = "563904425760", vpc_cidr = "10.14.0.0/16" }
},
{
hub = "54387632457"
ou_name = "test2"
spokes = [
{ spoke = "934960631748", vpc_cidr = "10.13.0.0/16" },
{ spoke = "43892321454", vpc_cidr = "10.14.0.0/16" }
}
]
【问题讨论】:
标签: terraform terraform-provider-aws terraform0.12+