DEV Community

Discussion on: Terraform: Variable validation with samples

Collapse
 
entscheidungsproblem profile image
entscheidungsproblem • Edited

This is a great article, thanks!

I've found that the IPV4 method fails for /32 ips:

> cidrhost("0.0.0.0/32",32)
╷
│ Error: Error in function call
│ 
│   on <console-input> line 1:
│   (source code not available)
│ 
│ Call to function "cidrhost" failed: prefix of 32 does not accommodate a host numbered 32.
╵
Enter fullscreen mode Exit fullscreen mode

But by replacing 32 with 0 as the second argument, it works:

> cidrhost("0.0.0.0/32",0)
"0.0.0.0"
> cidrhost("0.0.0.0/0",0)
"0.0.0.0"
Enter fullscreen mode Exit fullscreen mode

This also works for IPv6:

> cidrhost("0000:0000:0000:0000:0000:0000:0000:0001/128",0)
"::1"
Enter fullscreen mode Exit fullscreen mode
Collapse
 
drewmullen profile image
drewmullen

oh man that is a great find! thank you for reporting. cited you as well! :cheers: