Open mxk opened 2 months ago
Thanks for reporting this, @mxk.
I think the cause of this behavior is upstream in github.com/apparentlymart/go-cidr
, in the NextSubnet
function which seems to have a special case for all-zero addresses: https://github.com/apparentlymart/go-cidr/blob/d07067359aee8ee9101c1a79a4f286cf0cea059f/cidr/cidr.go#L195-L197
I don't recall what that special case was intending to achieve -- it's been a long time since that code was merged -- so I think it'll take some further poking to understand why that was there and whether it's load-bearing.
Terraform Version
Terraform Configuration Files
Debug Output
https://gist.github.com/mxk/c1b54ada0c08ecaae0296420904668f5
Expected Behavior
Both outputs should be identical.
Actual Behavior
cidrsubnets("0.0.0.0/1", 1, 1)
fails withInvalid value for "newbits" parameter: not enough remaining address space for a subnet with a prefix of 2 bits after 192.0.0.0/2.
(if the try call is removed).Steps to Reproduce
terraform plan
Additional Context
No response
References
No response