Hi there,
I have set of inputs like this:
---
vpc_list:
main:
cidr: 10.2.220.0/20
endpoints_if: [
ec2,
logs
]
extra:
cidr: 10.3.220.0/27
endpoints_if: [
]
# Default Interface Endpoints
vpc_endpoints_if:
- ec2
- monitoring
- kms
and from there, either I can produce two sets of lists:
> keys(var.vpc_list)
[
"main",
"extra",
]
and
> [for key in keys(var.vpc_list) : setunion(var.vpc_endpoints_if, var.vpc_list[key]["endpoints_if"])]
[
[
"ec2",
"kms",
"logs",
"monitoring",
],
[
"ec2",
"kms",
"monitoring",
],
]
or a list of keys and the corresponding list of values:
> zipmap(keys(var.vpc_list), [for key in keys(var.vpc_list) : setunion(var.vpc_endpoints_if, var.vpc_list[key]["endpoints_if"])])
{
"main" = [
"ec2",
"kms",
"logs",
"monitoring",
]
"extra" = [
"ec2",
"kms",
"monitoring",
]
}
From there, how can I create two individual setproducts
, for main
and extra
each and then combine those two and get some thing like this?
[
[
"main",
"ec2",
],
[
"main",
"log",
],
.....
[
"extra",
"ec2",
],
.....
]
so that I can feed that in when create the VPC endpoints:
resource "aws_vpc_endpoint" "if_eps" {
for_each = {
for pair in setproduct(--the-magic-recipe--) :
"${pair[0]}:${pair[1]}" => {
vpc_key = pair[0]
ep_name = pair[1]
}
}
....
Am I thinking right or there is a better way of doing it? Any help would be really appreciated.
-S