Closed jnearing-kabam closed 2 years ago
Following up on this per @laurapacilio's request.
The output of the network_subnets
locals value would look something like:
{
"cidr_block" = "10.1.16.0/20"
"network_id" = "vpc-0bfb00ca6173ea5aa"
"network_key" = "a"
"subnet_key" = "a"
},
{
"cidr_block" = "10.1.32.0/20"
"network_id" = "vpc-0bfb00ca6173ea5aa"
"network_key" = "a"
"subnet_key" = "b"
},
{
"cidr_block" = "10.1.48.0/20"
"network_id" = "vpc-0bfb00ca6173ea5aa"
"network_key" = "a"
"subnet_key" = "c"
},
{
"cidr_block" = "10.2.16.0/20"
"network_id" = "vpc-0d193e011f6211a7d"
"network_key" = "b"
"subnet_key" = "a"
},
{
"cidr_block" = "10.2.32.0/20"
"network_id" = "vpc-0d193e011f6211a7d"
"network_key" = "b"
"subnet_key" = "b"
},
{
"cidr_block" = "10.2.48.0/20"
"network_id" = "vpc-0d193e011f6211a7d"
"network_key" = "b"
"subnet_key" = "c"
},
]
Tested with a terraform.tfvars
file with a map of two base cidr blocks and three subnets per availability zone.
If I'm understanding the configuration correctly, the setproduct
function pairs the two maps from the networks & subnets locals values and creates a unique block of values to assign cidr_blocks from the base_cidr_block between the regions availability zones.
Thank you so much @tr0njavolta! I'm creating a PR to add this to the official documentation as well. @jnearing-kabam - thank you for this feedback! Let us know if you have additional questions or suggestions.
In the examples here: https://www.terraform.io/docs/configuration/functions/setproduct.html#finding-combinations-for-for_each
There is the definition for
network_subnets
. It would be easier to grok this example if there was a comment block with the variable structureSomething that would look like
Not that the above is probably not the structure network_subnets provides. I have no idea what the actual structure is, which is why Im requesting the structure be made available somewhere.