title: Use the existing Subnet details instead of creating again while creating Network Interface in Azure using terraform
body: <p>I'm trying to create network Interface in Azure through terraform using below script :   </p>
  
  <pre><code>resource "azurerm_subnet" "internal" {
    name                 = "Subnet1"
    resource_group_name  = "${var.VNetResourceGroup}"
    virtual_network_name = "${var.VNetName}"
    address_prefix       = "10.0.2.0/24"
  }
  
  resource "azurerm_network_interface" "main" {
    name                = "${var.prefix}-nic"
    location            = "${var.location}"
    resource_group_name = "${var.resourceGroup}"
  
    ip_configuration {
      name                          = "ipconfig1"
      subnet_id                     = "${azurerm_subnet.internal.id}"
      private_ip_address_allocation = "dynamic"
    }
  }
  </code></pre>
  
  <p>This script creates the Subnet <code>Subnet1</code> and assigning that <code>Subnet.id</code> in <code>ipconfiguration</code>.  </p>
  
  <p>But if I have to create another network interface again through another <code>.tf</code> file with the same <code>Subnet1</code> , how to do I get the <code>${azurerm_subnet.internal.id}</code> value again.   </p>
  
  <p>That is if the Subnet is already existing and I do not want to create it, how to I set those values and use them?</p>
  
  <p><strong>EDIT</strong>  </p>
  
  <p>I have figured out, in powershell this is the script used to determine Subnet id :</p>
  
  <pre><code>$vnetId= "[resourceId("VNetRG",'Microsoft.Network/virtualNetworks', "VNetName")]"
  $subnetRef = "[concat($vnetId, '/subnets/', "Subnet1")]"
  </code></pre>
  
  <p>where VNetRG - resource group of VNet  ,<br>
        VNetName - Name of VNet ,<br>
        Subnet1 - Name of Subnet.  </p>
  
  <p>Can anyone tell me what is the equivalent script in terraform?  </p>