Get IP from externally created load balancers with terraform

9/8/2019

I'm working on a terraform module to create a GKE cluster. The same module invokes a provisioner that performs a helm install of an application.

The helm chart creates load balancer. The load balancer is not know to the terraform module so that the assigned IP address can't be reused in the module.

Question:

How can I use the IP of the load balancer to create DNS entries and get certificates?

I think this is no exotic use case but I haven't yet found a decent way to achieve this.

-- Randy
kubernetes
terraform
terraform-provider-gcp
terraform-provider-kubernetes

1 Answer

9/13/2019

The correct answer to this question is:

The data source of the kubernetes_service.

The concept of Data Source is exactly solving the issue here.

Appart from the above kubernetes_service data source I could have also ran a shell script with kubectl querying the ip and use External Data Source as a generic solution.

From there I can use the IP address in a dns provider and in an acme provider to create dns entries and certificates.

-- Randy
Source: StackOverflow