I want to combine 2 variables. I tried to use locales but I couldn't get the final result also even with flatten
Any other recommendation? I tried to use this structure since the vpc module receives that object with a list of subnets, the idea is that in networks we can add the name of the subnet in the list
variable "subnets" {
default = {
"subnet-01" = {
name = "subnet-01"
subnet_ip = "10.10.10.0/24"
subnet_region = "us-central1"
description = "This subnet has a description"
}
"subnet-02" = {
name = "subnet-02"
subnet_ip = "10.10.20.0/24"
subnet_region = "us-central1"
description = "This subnet has a description"
}
"subnet-03" = {
name = "subnet-03"
subnet_ip = "10.10.20.0/24"
subnet_region = "us-central1"
description = "This subnet has a description"
}
}
}
variable "networks" {
default = {
"test-network" = {
subnets = ["subnet-01", "subnet-02"]
auto_create_subnetworks = "false"
mtu = "0"
}
"test-network-2" = {
subnets = ["subnet-03"]
auto_create_net = false
auto_create_subnetworks = "false"
mtu = "0"
}
}
}
Is it possible to choose the following result?
networks = {
test-network = {
auto_create_subnetworks = false
mtu = 0
subnets = [
subnet-01 = {
name = "subnet-01"
subnet_ip = "10.10.10.0/24"
subnet_region = "us-central1"
description = "This subnet has a description"
}
subnet-02 = {
name = "subnet-02"
subnet_ip = "10.10.20.0/24"
subnet_region = "us-central1"
description = "This subnet has a description"
}
]
}
test-network-2 = {
auto_create_subnetworks = false
mtu = 0
subnets = [
subnet-03 = {
name = "subnet-03"
subnet_ip = "10.10.30.0/24"
subnet_region = "us-central1"
description = "This subnet has a description"
}
]
}
}