github.com/kevinklinger/open_terraform@v1.3.6/noninternal/lang/globalref/testdata/contributing-resources/network/contributing-resources-network.tf (about) 1 variable "base_cidr_block" { 2 type = string 3 } 4 5 variable "subnet_count" { 6 type = number 7 } 8 9 locals { 10 subnet_newbits = log(var.subnet_count, 2) 11 subnet_cidr_blocks = toset([ 12 for n in range(var.subnet_count) : cidrsubnet(var.base_cidr_block, local.subnet_newbits, n) 13 ]) 14 } 15 16 resource "test_thing" "vpc" { 17 string = var.base_cidr_block 18 } 19 20 resource "test_thing" "subnet" { 21 for_each = local.subnet_cidr_blocks 22 23 string = test_thing.vpc.string 24 single { 25 z = each.value 26 } 27 } 28 29 resource "test_thing" "route_table" { 30 for_each = local.subnet_cidr_blocks 31 32 string = each.value 33 } 34 35 output "vpc_id" { 36 value = test_thing.vpc.string 37 } 38 39 output "subnet_ids" { 40 value = { for k, sn in test_thing.subnet : k => sn.string } 41 }