From ace46e9669e24cad53bc7d01b5098922a8b037be Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Thu, 13 Sep 2018 13:24:29 -0700 Subject: [PATCH] core: EvalWriteOutput discard unknown values before writing state The state only deals in wholly-known values, so here we null out any unknowns for storage in state. This is okay because we subsequently write the original, possibly-unknown value into the plan and the expression evaluator will prefer to use this if present, allowing the unknown values to properly propagate into other expressions in the calling module. --- terraform/eval_output.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/terraform/eval_output.go b/terraform/eval_output.go index 384bc9150a..6829934f0e 100644 --- a/terraform/eval_output.go +++ b/terraform/eval_output.go @@ -68,7 +68,11 @@ func (n *EvalWriteOutput) Eval(ctx EvalContext) (interface{}, error) { } if val.IsKnown() && !val.IsNull() { - state.SetOutputValue(addr, val, n.Sensitive) + // The state itself doesn't represent unknown values, so we null them + // out here and then we'll save the real unknown value in the planned + // changeset below, if we have one on this graph walk. + stateVal := cty.UnknownAsNull(val) + state.SetOutputValue(addr, stateVal, n.Sensitive) } else { state.RemoveOutputValue(addr) }