Skip to content

Commit

Permalink
chore: try() to fix index errors (#62)
Browse files Browse the repository at this point in the history
this fixes: #61
  • Loading branch information
ephur authored Nov 25, 2020
1 parent e7a00f9 commit 265cb28
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 265cb28

Please sign in to comment.