From 43f2eea3104561ec3e390cc49d0e729bcdd8f4e4 Mon Sep 17 00:00:00 2001 From: Riley Karson Date: Thu, 10 Jan 2019 17:26:32 +0000 Subject: [PATCH] Fix next_instance_zone for google_compute_route Signed-off-by: Modular Magician --- google/resource_compute_route.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/google/resource_compute_route.go b/google/resource_compute_route.go index e30c5de39d9..eae0a98d36a 100644 --- a/google/resource_compute_route.go +++ b/google/resource_compute_route.go @@ -454,11 +454,18 @@ func expandComputeRouteNextHopGateway(v interface{}, d *schema.ResourceData, con } func expandComputeRouteNextHopInstance(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) { - f, err := parseZonalFieldValue("instances", v.(string), "project", "zone", d, config, true) + if v == "" { + return v, nil + } + val, err := parseZonalFieldValue("instances", v.(string), "project", "next_hop_instance_zone", d, config, true) if err != nil { - return nil, fmt.Errorf("Invalid value for next_hop_instance: %s", err) + return nil, err } - return f.RelativeLink(), nil + nextInstance, err := config.clientCompute.Instances.Get(val.Project, val.Zone, val.Name).Do() + if err != nil { + return nil, err + } + return nextInstance.SelfLink, nil } func expandComputeRouteNextHopIp(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {