<p>Lets assume I have an existing GKE cluster that contains all my applications. They were all deployed using different methods. Now I want to deploy some resources to that cluster using Terraform. The trouble here is that terraform doesn't see it in his state file so it can't interact with it. Another problem is that even if I get that cluster to my state file, terraform doesn't see all of the created resources in that cluster. This could lead to some conflicts e.g. I'm trying to deploy two resources with the same name. Is there a way to solve this problem or do I just have to deal with the reality of my existence and create a new cluster for every new project that I deploy with terraform?</p>

SyntioBen
<p>You can use terraform <a href="https://www.terraform.io/docs/cli/commands/import.html" rel="nofollow noreferrer">import command</a> to import your existing GKE cluster to terraform state. Prior to run it, you need to have the adequate terraform configuration for your cluster.</p>
<p>example of import command :</p>
<pre><code>terraform import google_container_cluster.&lt;TF_RESOURCE_NAME&gt; projects/&lt;PROJECT_ID&gt;/locations/&lt;YOUR-CLUSTER-ZONE&gt;/clusters/&lt;CLUSTER_NAME&gt;
</code></pre>
<p>for a terraform configuration :</p>
<pre><code>resource &quot;google_container_cluster&quot; &quot;&lt;TF_RESOURCE_NAME&gt;&quot; {
  name     = &quot;&lt;CLUSTER_NAME&gt;&quot;
  location = &quot;&lt;YOUR-CLUSTER-ZONE&gt;&quot;

}
</code></pre>
<p>The CLUSTER_NAME is the name displayed in your GKE clusters list on Google Cloud Console.</p>
<p>Then you need also to import the cluster node pool(s) in the same way using terraform <code>google_container_node_pool</code> resource.</p>
