Skip to content

Commit b799266

Browse files
authored
fix: Resolve Invalid index error on shared vpc destroy (#177)
Checks that google_compute_shared_vpc_host_project.shared_vpc_host is not empty before attempting to return the value. Avoids the error "google_compute_shared_vpc_host_project.shared_vpc_host is empty tuple The given key does not identify an element in this collection value."
1 parent 0062602 commit b799266

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

modules/vpc/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ output "network_self_link" {
3030
}
3131

3232
output "project_id" {
33-
value = var.shared_vpc_host ? google_compute_shared_vpc_host_project.shared_vpc_host.*.project[0] : google_compute_network.network.project
33+
value = var.shared_vpc_host && length(google_compute_shared_vpc_host_project.shared_vpc_host) > 0 ? google_compute_shared_vpc_host_project.shared_vpc_host.*.project[0] : google_compute_network.network.project
3434
description = "VPC project id"
3535
}

0 commit comments

Comments
 (0)