diff --git a/terraform/eval_read_data.go b/terraform/eval_read_data.go index f9924b29e..2eb9960d3 100644 --- a/terraform/eval_read_data.go +++ b/terraform/eval_read_data.go @@ -22,9 +22,10 @@ type EvalReadDataDiff struct { ProviderAddr addrs.AbsProviderConfig ProviderSchema **ProviderSchema - Output **plans.ResourceInstanceChange - OutputValue *cty.Value - OutputState **states.ResourceInstanceObject + Output **plans.ResourceInstanceChange + OutputValue *cty.Value + OutputConfigValue *cty.Value + OutputState **states.ResourceInstanceObject // Set Previous when re-evaluating diff during apply, to ensure that // the "Destroy" flag is preserved. @@ -114,10 +115,12 @@ func (n *EvalReadDataDiff) Eval(ctx EvalContext) (interface{}, error) { if n.Output != nil { *n.Output = change } - if n.OutputValue != nil { *n.OutputValue = change.After } + if n.OutputConfigValue != nil { + *n.OutputConfigValue = configVal + } if n.OutputState != nil { state := &states.ResourceInstanceObject{ diff --git a/terraform/node_data_refresh.go b/terraform/node_data_refresh.go index 65da5dffb..1993faf2d 100644 --- a/terraform/node_data_refresh.go +++ b/terraform/node_data_refresh.go @@ -145,13 +145,13 @@ func (n *NodeRefreshableDataResourceInstance) EvalTree() EvalNode { }, &EvalReadDataDiff{ - Addr: addr.Resource, - Config: n.Config, - ProviderAddr: n.ResolvedProvider, - ProviderSchema: &providerSchema, - Output: &change, - OutputValue: &configVal, - OutputState: &state, + Addr: addr.Resource, + Config: n.Config, + ProviderAddr: n.ResolvedProvider, + ProviderSchema: &providerSchema, + Output: &change, + OutputConfigValue: &configVal, + OutputState: &state, }, // The rest of this pass can proceed only if there are no