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:
<code>azs =
{ "list1" = tolist([ "eu-west-2a", "eu-west-2b", "eu-west-2c", ])
"list2" = tolist([ "eu-west-2a", "eu-west-2b", "eu-west-2c", ]) }
private_subnets =
{ "subnets1" = [ "subnet-a", "subnet-b", "subnet-c", ]
"subnets2" = [ "subnet-d", "subnet-e", "subnet-f", ] }
</code>
<code>azs =
{ "list1" = tolist([ "eu-west-2a", "eu-west-2b", "eu-west-2c", ])
"list2" = tolist([ "eu-west-2a", "eu-west-2b", "eu-west-2c", ]) }
private_subnets =
{ "subnets1" = [ "subnet-a", "subnet-b", "subnet-c", ]
"subnets2" = [ "subnet-d", "subnet-e", "subnet-f", ] }
</code>
azs =
{ "list1" = tolist([ "eu-west-2a", "eu-west-2b", "eu-west-2c", ])
"list2" = tolist([ "eu-west-2a", "eu-west-2b", "eu-west-2c", ]) }
private_subnets =
{ "subnets1" = [ "subnet-a", "subnet-b", "subnet-c", ]
"subnets2" = [ "subnet-d", "subnet-e", "subnet-f", ] }
Required result:
if list1 variable is matched then return list1 & subnets1 as per below. If list2 variable is matched then return list2 & subnets2.
list1 variable result:
<code>subnets = {
"eu-west-2a" = { id = "subnet-a" },
"eu-west-2b" = { id = "subnet-b" },
"eu-west-2c" = { id = "subnet-c" },
}
</code>
<code>subnets = {
"eu-west-2a" = { id = "subnet-a" },
"eu-west-2b" = { id = "subnet-b" },
"eu-west-2c" = { id = "subnet-c" },
}
</code>
subnets = {
"eu-west-2a" = { id = "subnet-a" },
"eu-west-2b" = { id = "subnet-b" },
"eu-west-2c" = { id = "subnet-c" },
}
I have researched join command but that does not combine line by line.
New contributor
BP2000 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.