First and most important thanks in advance for assistance on this one.
I have two TF output maps below from vpc creation that need to be combined into required result:
azs = { "vpc_name1" = tolist([ "eu-west-2a", "eu-west-2b", "eu-west-2c", ]) "vpc_name2" = tolist([ "eu-west-2a", "eu-west-2b", "eu-west-2c", ]) } private_subnets = { "vpc_name1" = [ "subnet-a", "subnet-b", "subnet-c", ] "vpc_name2" = [ "subnet-d", "subnet-e", "subnet-f", ] }
Required result:If vpc_name1 is selected return subnets1 output below. If vpc_name2 is selected return subnets2 output.
module "xxx” { for_each = var.x subnets = each.value.vpc_name == "vpc_name1" ? // return subnets1}
vpc_name1 output:
subnets1 = {"eu-west-2a" = { id = "subnet-a" },"eu-west-2b" = { id = "subnet-b" },"eu-west-2c" = { id = "subnet-c" },}
vpc_name2 output:
subnets2 = {"eu-west-2a" = { id = "subnet-d" },"eu-west-2b" = { id = "subnet-e" },"eu-west-2c" = { id = "subnet-f" },}
I have researched join command but that does not combine line by line.