You're looking at documentation for Terraform v1.1 and earlier. Click here to view the latest content.
A new platform for documentation and tutorials is launching soon.
We are migrating Terraform documentation into HashiCorp Developer, our new developer experience.
cidrnetmask converts an IPv4 address prefix given in CIDR notation into
a subnet mask address.
prefix must be given in IPv4 CIDR notation, as defined in
RFC 4632 section 3.1.
The result is a subnet address formatted in the conventional dotted-decimal IPv4 address syntax, as expected by some software.
CIDR notation is the only valid notation for IPv6 addresses, so
produces an error if given an IPv6 address.
Note: As a historical accident, this function interprets IPv4 address octets that have leading zeros as decimal numbers, which is contrary to some other systems which interpret them as octal. We have preserved this behavior for backward compatibility, but recommend against relying on this behavior.
> cidrnetmask("172.16.0.0/12") 255.240.0.0