title: How do I make a field optional inside a terraform resource?
body: <p>I am trying to create VMs for both cluster and single node deployments. </p>
  
  <pre><code>resource "azurerm_virtual_machine" "app" {
      name   = "${var.name_prefix}-${format("%02d", count.index+1)}"
      location = "${var.location}"
      resource_group_name = "${azurerm_resource_group.resourcegroup.name}"
      availability_set_id   = "${azurerm_availability_set.avset.id}"
      network_interface_ids = ["${element(azurerm_network_interface.networkinterface-app.*.id, count.index+1)}"]
      vm_size = "${var.vm_size}"
      count = "${var.app_nodes}"
  </code></pre>
  
  <p>The setup works well for the cluster node deployments with <code>availability_set_id</code> configured but fails as in single node I don't have a need to configure <code>availability_set_id</code>. </p>
  
  <p>I am using <code>Terraform v0.11.2</code> and <code>* provider.azurerm: version = "~&gt; 1.0"</code> as versions of terraform and azurerm provider currently.</p>
  
  <p>Can anyone help me how to use a conditional in this case to handle both scenarios?</p>