From 265cb28bff22510c9991879ada281452b3c9fb9b Mon Sep 17 00:00:00 2001 From: Richard Maynard Date: Wed, 25 Nov 2020 12:02:04 -0600 Subject: [PATCH] chore: try() to fix index errors (#62) this fixes: https://github.com/terraform-google-modules/terraform-google-bastion-host/issues/61 --- main.tf | 2 +- outputs.tf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index a7eb8b76..e6ffa977 100644 --- a/main.tf +++ b/main.tf @@ -95,7 +95,7 @@ module "iap_tunneling" { network = var.network service_accounts = [local.service_account_email] instances = var.create_instance_from_template ? [{ - name = google_compute_instance_from_template.bastion_vm[0].name + name = try(google_compute_instance_from_template.bastion_vm[0].name, "") zone = var.zone }] : [] members = var.members diff --git a/outputs.tf b/outputs.tf index 45ba97b6..3c75d473 100644 --- a/outputs.tf +++ b/outputs.tf @@ -25,12 +25,12 @@ output "hostname" { output "ip_address" { description = "Internal IP address of the bastion host" - value = var.create_instance_from_template ? google_compute_instance_from_template.bastion_vm[0].network_interface.0.network_ip : "" + value = try((var.create_instance_from_template ? google_compute_instance_from_template.bastion_vm[0].network_interface.0.network_ip : ""), "") } output "self_link" { description = "Self link of the bastion host" - value = var.create_instance_from_template ? google_compute_instance_from_template.bastion_vm[0].self_link : "" + value = try((var.create_instance_from_template ? google_compute_instance_from_template.bastion_vm[0].self_link : ""), "") } output "instance_template" {