title: Error while provisioning Terraform subnet using azurerm
body: <p>Recently i figured out that my AKS cluster holds a subnet which is too small. Therefor im trying to add a second subnet and nodepool which is possible with the Azure CNI nowadays and then create a single proper subnet instead and migrate it back.</p>
  <p>During <code>terraform plan</code> all goes well with a valid response however while applying it throws an error.</p>
  <pre><code>Error: Error Creating/Updating Subnet &quot;me-test-k8s-subnet2&quot; (Virtual Network &quot;me-test-k8s-vnet&quot; / Resource Group &quot;me-test-k8s-rg&quot;): network.SubnetsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code=&quot;NetcfgInvalidSubnet&quot; Message=&quot;Subnet 'me-test-k8s-subnet2' is not valid in virtual network 'me-test-k8s-vnet'.&quot; Details=[]
  
    on main.tf line 28, in resource &quot;azurerm_subnet&quot; &quot;subnet2&quot;:
    28: resource &quot;azurerm_subnet&quot; &quot;subnet2&quot; {
  </code></pre>
  <p>My original cluster is created with this configuration of <code>Terraform</code>:</p>
  <pre><code>  name     = &quot;${var.cluster_name}-rg&quot;
    location = &quot;${var.location}&quot;
  }
  
  resource &quot;azurerm_virtual_network&quot; &quot;network&quot; {
    name                = &quot;${var.cluster_name}-vnet&quot;
    location            = &quot;${azurerm_resource_group.rg.location}&quot;
    resource_group_name = &quot;${azurerm_resource_group.rg.name}&quot;
    address_space       = [&quot;10.1.0.0/16&quot;]
  }
  
  resource &quot;azurerm_subnet&quot; &quot;subnet&quot; {
    name                 = &quot;${var.cluster_name}-subnet&quot;
    resource_group_name  = &quot;${azurerm_resource_group.rg.name}&quot;
    address_prefixes     = [&quot;10.1.0.0/24&quot;]
    virtual_network_name = &quot;${azurerm_virtual_network.network.name}&quot;
  }
  </code></pre>
  <p>To make things more easy i decided to first add the subnet to the network without the nodepool. This will bring me to this terraform plan:</p>
  <pre><code>An execution plan has been generated and is shown below.
  Resource actions are indicated with the following symbols:
    + create
  
  Terraform will perform the following actions:
  
    # azurerm_subnet.subnet2 will be created
    + resource &quot;azurerm_subnet&quot; &quot;subnet2&quot; {
        + address_prefix                                 = (known after apply)
        + address_prefixes                               = [
            + &quot;10.2.0.0/22&quot;,
          ]
        + enforce_private_link_endpoint_network_policies = false
        + enforce_private_link_service_network_policies  = false
        + id                                             = (known after apply)
        + name                                           = &quot;me-test-k8s-subnet2&quot;
        + resource_group_name                            = &quot;me-test-k8s-rg&quot;
        + virtual_network_name                           = &quot;me-test-k8s-vnet&quot;
      }
  </code></pre>
  <p>Hope that someone can explain me why this error occurs.</p>
  <p>Best,
  Pim</p>