From f86dc22caf73a6b7b75c9a94144fbad508f1182b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 11 May 2015 14:57:20 -0700 Subject: [PATCH] terraform: return unknown if resource not found --- terraform/interpolate.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/terraform/interpolate.go b/terraform/interpolate.go index b0af5f6596..96c2c75219 100644 --- a/terraform/interpolate.go +++ b/terraform/interpolate.go @@ -321,10 +321,7 @@ func (i *Interpolater) computeResourceVariable( r = nil } if r == nil { - return "", fmt.Errorf( - "Resource '%s' not found for variable '%s'", - id, - v.FullKey()) + goto MISSING } if r.Primary == nil { @@ -367,6 +364,13 @@ func (i *Interpolater) computeResourceVariable( } MISSING: + // Validation for missing interpolations should happen at a higher + // semantic level. If we reached this point and don't have variables, + // just return the computed value. + if scope == nil || scope.Resource == nil { + return config.UnknownVariableValue, nil + } + // If the operation is refresh, it isn't an error for a value to // be unknown. Instead, we return that the value is computed so // that the graph can continue to refresh other nodes. It doesn't