terraform-aws-named-subnets icon indicating copy to clipboard operation
terraform-aws-named-subnets copied to clipboard

Add an optional variable to specify a netnum offset

Open robgonnella opened this issue 3 years ago • 1 comments

Describe the Feature

Allow users to specify an offset for the netnum value when calculating subnet cidr blocks. e.g.

subnet_names = ["one", "two"]
cidr_block = 10.10.0.0/16
netnum_offset = 1

Which would result in 2 subnets with cidr blocks, 10.10.16.0/20 and 10.10.32.0/20

Expected Behavior

Specifying a netnum offset would offset the call to cidrsubnet by the given value e.g.

cidrsubnet(var.cidr_block, ceil(log(var.max_subnets, 2)), count.index + var.netnum_offset)

Use Case

This valuable in cases where you want to use available addresses in a cidr block before needing to add an additional cidr block to the vpc.

Describe Ideal Solution

An optional variable (type = number) is added to the module that allows specification of a netnum offset. This offset is then used to offset the netnum value when calculating the subnet cidr block via the call to the cidrsubnet function.

Alternatives Considered

I could just add a new cidr block to the vpc, forego any netnum offset, and calling it a day. This is a totally valid and easy solution, but the addition of an offset doesn't seem too difficult either, and maybe someone else would also find value in this option.

robgonnella avatar Oct 01 '21 19:10 robgonnella