<p>I've been using a kubernetes ingress config file to assign a static external ip address created by GCP.
The ingress and the deployment are managed by GKE.</p>
<p>ingress.yaml</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: test-address
spec:
  backend:
    serviceName: test-service
    servicePort: 80
</code></pre>
<p>With this yaml file, the static ip address created already is successfully attached to the ingress.</p>
<p>On External IP Address on VPC Network menu, the ip is in use by forwarding rule.</p>
<p><code>Name           External Address   Region        Type  Version     In use by</code></p>
<p><code>test-address   12.34.56.78     asia-northeast2 Static  IPv4     Forwarding rule k8s2-ab-blablablabla</code></p>
<p>However, Recently I tried to test Terraform to deploy the infrastructure to GCP and I made a Terraform config file exactly the same with above ingress.yaml.</p>
<p>ingress.tf</p>
<pre><code>resource &quot;kubernetes_ingress&quot; &quot;test_ingress&quot; {
  metadata {
    name = &quot;test-ingress&quot;
    annotations = {
      &quot;kubernetes.io/ingress.global-static-ip-name&quot; = &quot;test-address&quot;
    }
  }
  spec {
    backend {
      service_name = test-service
      service_port = &quot;80&quot;
    }
  }
}
</code></pre>
<p>After I apply this config to GCP, the ingress was created successfully but the ip address does not attach to the ingress.</p>
<p>In Ingress detail in GCP, an error occurred with the message</p>
<p><code>Error syncing to GCP: error running load balancer syncing routine: loadbalancer blablablablabla does not exist: the given static IP name test-address doesn't translate to an existing static IP.</code></p>
<p>And on External IP Address on VPC Network menu, the IP address row at <code>In use by</code> shows <code>None</code>.</p>
<p>What is the problem here? Did I miss something with Terraform?</p>

Eric Lee
<p>As @MattBrowne said in the comments, needs to be global IP and not regional. This also fixed for me.</p>
