From a2718e4f790d48f57c9769648cd6b3da435355f7 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 9 Mar 2018 19:07:28 -0500 Subject: [PATCH] ignore errors interpolating RawCount during apply If a count field references another count field which is interpolated but is attached to a resource already in the state, the result of that first interpolation will be lost when a plan is serialized. This is because the result of the first interpolation is stored directly in the module config, in an unexported config field. This is not a general fix for the above situation, which would require refactoring how counts are handles throughout the config. Ignoring the error works, because in most cases the count will be properly handled during the resource's interpolation. --- terraform/node_resource_apply.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/terraform/node_resource_apply.go b/terraform/node_resource_apply.go index 9044806559..40ee1cf2a7 100644 --- a/terraform/node_resource_apply.go +++ b/terraform/node_resource_apply.go @@ -140,7 +140,10 @@ func (n *NodeApplyableResource) evalTreeDataResource( // Here we are just populating the interpolated value in-place // inside this RawConfig object, like we would in // NodeAbstractCountResource. - &EvalInterpolate{Config: n.Config.RawCount}, + &EvalInterpolate{ + Config: n.Config.RawCount, + ContinueOnErr: true, + }, // We need to re-interpolate the config here, rather than // just using the diff's values directly, because we've @@ -271,7 +274,10 @@ func (n *NodeApplyableResource) evalTreeManagedResource( // Here we are just populating the interpolated value in-place // inside this RawConfig object, like we would in // NodeAbstractCountResource. - &EvalInterpolate{Config: n.Config.RawCount}, + &EvalInterpolate{ + Config: n.Config.RawCount, + ContinueOnErr: true, + }, &EvalInterpolate{ Config: n.Config.RawConfig.Copy(),