<p>We use Terraform to create all of our infrastructure resources then we use Helm to deploy apps in our cluster.</p>
<p>We're looking for a way to streamline the creation  of infra and apps, so currently this is what we do:</p>
<ul>
<li>Terraform creates kubernetes cluster, VPC network etc and a couple of static public IP addresses</li>
<li>We have to wait for the dynamic creation of these static IPs by Terraform to complete</li>
<li>We find out what the public IP is that's been created, and manually add that to our <code>loadBalancerIP:</code> spec on our ingress controller helm chart</li>
</ul>
<p>If at all possible, I'd like to store the generated public IP somewhere via terraform (config map would be nice), and then reference that in the ingress service <code>loadBalancerIP:</code> spec, so the end to end process is sorted.</p>
<p>I know configmaps are for pods and I don't <em>think</em> they can be used for kubernetes service objects - does anyone have any thoughts/ideas on how I could achieve this?</p>

<p>I suggest creating a static public IP in GCP using terraform by specifying the name you want like this:</p>
<pre class="lang-json prettyprint-override"><code>module &quot;address&quot; {
  source       = &quot;terraform-google-modules/address/google&quot;
  version      = &quot;3.0.0&quot;
  project_id   = &quot;your-project-id&quot;
  region       = &quot;your-region&quot;
  address_type = &quot;EXTERNAL&quot;
  names = [ &quot;the-name-you-want&quot; ]
  global = true
}
</code></pre>
<p>You can then refer to this static public IP <code>name</code> in the Kubernetes ingress resource by specifying the annotations <code>kubernetes.io/ingress.global-static-ip-name: &quot;the-name-you-want&quot;</code> like this:</p>
<pre class="lang-json prettyprint-override"><code>resource &quot;kubernetes_ingress_v1&quot; &quot;example&quot; {
  wait_for_load_balancer = true
  metadata {
    name = &quot;example&quot;
    namespace = &quot;default&quot;
    annotations = {
      &quot;kubernetes.io/ingress.global-static-ip-name&quot; = &quot;the-name-you-want&quot;
    }
  }
  spec {
....
</code></pre>
<p>This will create ingress resource 'example' in GKE and attach static public IP named 'the-name-you-want' to it.</p>
