title: How to add or remove access_config on terraform GCP with variable
body: <p>How to add or remove block code <strong>access_config { }</strong> on terraform with GCP.</p>
  <p>I have variable:</p>
  <pre><code>external_ip = false
  </code></pre>
  <p>if external IP is value <strong>false</strong> code:</p>
  <pre><code>
  resource &quot;google_compute_instance_from_template&quot; &quot;default_name_index&quot; {
    name  = &quot;${length(var.instances[change_with_index].instance_backup_ip) == 1 ? var.instances[change_with_index].instance_backup_name : format(&quot;%s-%s&quot;, var.instances[change_with_index].instance_backup_name, count.index + 1)}&quot;
    count = length(var.instances[change_with_index].instance_backup_ip)
  
    source_instance_template = &quot;projects/${var.provider_project}/global/instanceTemplates/${replace(var.instances[change_with_index].instance_name, &quot;-app-image&quot;, &quot;&quot;)}-${var.release_version}&quot;
  
    network_interface {
      network    = var.instances[change_with_index].instance_network
      subnetwork = var.instances[change_with_index].instance_subnetwork
      network_ip = var.instances[change_with_index].instance_backup_ip[count.index]
      
    }
  }
  </code></pre>
  <p>if external_ip is value <strong>true</strong> code:</p>
  <pre><code>
  resource &quot;google_compute_instance_from_template&quot; &quot;default_name_index&quot; {
    name  = &quot;${length(var.instances[change_with_index].instance_backup_ip) == 1 ? var.instances[change_with_index].instance_backup_name : format(&quot;%s-%s&quot;, var.instances[change_with_index].instance_backup_name, count.index + 1)}&quot;
    count = length(var.instances[change_with_index].instance_backup_ip)
  
    source_instance_template = &quot;projects/${var.provider_project}/global/instanceTemplates/${replace(var.instances[change_with_index].instance_name, &quot;-app-image&quot;, &quot;&quot;)}-${var.release_version}&quot;
  
    network_interface {
      network    = var.instances[change_with_index].instance_network
      subnetwork = var.instances[change_with_index].instance_subnetwork
      network_ip = var.instances[change_with_index].instance_backup_ip[count.index]
      
      #access_config will add in here
      access_config
      {
      }
  
    }
  }
  </code></pre>
  <p>thank u for helping me.</p>