From 7fd6f97899b1e04a2c69edb9d9e499b8fa04fb7d Mon Sep 17 00:00:00 2001 From: James Bardin Date: Tue, 6 Mar 2018 17:45:28 -0500 Subject: [PATCH] Check for nil config in node_resource_refresh While not normally possible, manual manipulation of the state and config can cause us to end up with a nil config in evalTreeManagedResourceNoState. Regardless of how it got here, we can't ever assume the Config field is not nil, and EvalInterpolate happily accepts a nil RawConfig --- terraform/node_resource_refresh.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/terraform/node_resource_refresh.go b/terraform/node_resource_refresh.go index dbb64edae..697bd4942 100644 --- a/terraform/node_resource_refresh.go +++ b/terraform/node_resource_refresh.go @@ -213,10 +213,16 @@ func (n *NodeRefreshableManagedResourceInstance) evalTreeManagedResourceNoState( // Determine the dependencies for the state. stateDeps := n.StateReferences() + // n.Config can be nil if the config and state don't match + var raw *config.RawConfig + if n.Config != nil { + raw = n.Config.RawConfig.Copy() + } + return &EvalSequence{ Nodes: []EvalNode{ &EvalInterpolate{ - Config: n.Config.RawConfig.Copy(), + Config: raw, Resource: resource, Output: &resourceConfig, },