title: Terraform CIDR block variable validation
body: <p><strong>Terraform variable validation for CIDR, looking alternative for regex</strong></p>
  <p>Below is the tested code in Terraform version 13.0
  is there any alternative way to achieve same thing with not using regex?</p>
  <p>cidr block - start 172.28.0.0.0/16</p>
  <pre><code>    variable &quot;vpc_cidr&quot; {
        description = &quot;Kubernetes cluster CIDR notation for vpc.&quot;
        validation {
          condition     = can(regex(&quot;^([0-9]{1,3}\\.){3}[0-9]{1,3}($|/(16))$&quot;, var.pod_cidr))
          error_message = &quot;Vpc_cidr value must be greater than 172.0.0.0/16.&quot;
        }
      }
  </code></pre>
  <p>how to validate CIDR block 172.28.x.x/16 with cidrsubnet function?
  <a href="https://www.terraform.io/docs/language/functions/cidrsubnet.html" rel="nofollow noreferrer">https://www.terraform.io/docs/language/functions/cidrsubnet.html</a></p>
  <p>validation condition - if IP range is outof 172.28.x.x/16 then validation will be failed</p>