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" {