How do you carve subnets with `cidrsubnet`?
IntermediateConceptLoops, Conditionals, Dynamic Blocks and Functions
Answer
cidrsubnet(prefix, newbits, netnum) adds newbits to the prefix length and picks the netnum-th block.
cidrsubnet("10.0.0.0/16", 8, 2) # "10.0.2.0/24"
cidrhost("10.0.2.0/24", 10) # "10.0.2.10"
cidrsubnets("10.0.0.0/16", 4, 4, 8) # several blocks of different size
More on Loops, Conditionals, Dynamic Blocks and Functions
How does `count` work?BeginnerHow does `for_each` work?BeginnerWhen should you choose `for_each` over `count`?IntermediateHow do you use `for_each` with a list of objects?IntermediateWhat does "The for_each value depends on resource attributes that cannot be determined until apply" mean?AdvancedHow do you create a resource conditionally?Beginner