From bfa94dc707d998953bc30c1886e070833068449b Mon Sep 17 00:00:00 2001 From: darox Date: Tue, 10 Oct 2023 17:12:49 +0200 Subject: [PATCH 1/2] add external ip output Signed-off-by: darox --- main.tf | 10 ++++++++++ outputs.tf | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/main.tf b/main.tf index e3db381..f3e9594 100644 --- a/main.tf +++ b/main.tf @@ -80,3 +80,13 @@ resource "null_resource" "kubeconfig" { } } } + +data "external" "external_ips" { + program = ["bash", "-c", "gcloud compute instances list --filter=\"name~${var.name}\" --format=\"json(networkInterfaces[0].accessConfigs[0].natIP)\" | jq 'to_entries | map({key: (.key|tostring), value: (.value|tostring)}) | from_entries'"] +} + +locals { + external_ips = [ + for value in data.external.external_ips.result : jsondecode(value).networkInterfaces[0].accessConfigs[0].natIP + ] +} \ No newline at end of file diff --git a/outputs.tf b/outputs.tf index b613591..790fb9c 100644 --- a/outputs.tf +++ b/outputs.tf @@ -12,6 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +output "external_ips" { + value = local.external_ips + description = "External IPs of the nodes" +} + output "id" { value = module.main.cluster_id } From 91e5babe16c0bbbecdd49b2fb50ecc4f3aa104b5 Mon Sep 17 00:00:00 2001 From: darox Date: Tue, 10 Oct 2023 17:19:34 +0200 Subject: [PATCH 2/2] fix typo Signed-off-by: darox --- outputs.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/outputs.tf b/outputs.tf index 790fb9c..f29b186 100644 --- a/outputs.tf +++ b/outputs.tf @@ -26,5 +26,5 @@ output "path_to_kubeconfig_file" { } output "zones" { - value = "module.main.zones" + value = module.main.zones }