@@ -513,10 +513,6 @@ func (n *NodeDestroyableOutput) DotNode(name string, opts *dag.DotOpts) *dag.Dot
513513}
514514
515515func (n * NodeApplyableOutput ) setValue (state * states.SyncState , changes * plans.ChangesSync , val cty.Value ) {
516- // If we have an active changeset then we'll first replicate the value in
517- // there and lookup the prior value in the state. This is used in
518- // preference to the state where present, since it *is* able to represent
519- // unknowns, while the state cannot.
520516 if changes != nil && n .Planning {
521517 // if this is a root module, try to get a before value from the state for
522518 // the diff
@@ -538,8 +534,8 @@ func (n *NodeApplyableOutput) setValue(state *states.SyncState, changes *plans.C
538534 }
539535 }
540536
541- // We will not show the value is either the before or after are marked
542- // as sensitivity . We can show the value again once sensitivity is
537+ // We will not show the value if either the before or after are marked
538+ // as sensitive . We can show the value again once sensitivity is
543539 // removed from both the config and the state.
544540 sensitiveChange := sensitiveBefore || n .Config .Sensitive
545541
@@ -601,22 +597,14 @@ func (n *NodeApplyableOutput) setValue(state *states.SyncState, changes *plans.C
601597 return
602598 }
603599
604- // The state itself doesn't represent unknown values, so we null them
605- // out here and then we'll save the real unknown value in the planned
606- // changeset, if we have one on this graph walk.
607600 log .Printf ("[TRACE] setValue: Saving value for %s in state" , n .Addr )
608- sensitive := n .Config .Sensitive
609- unmarkedVal , valueMarks := val .UnmarkDeep ()
610-
611- // If the evaluated value contains sensitive marks, the output has no
612- // choice but to declare itself as "sensitive".
613- for mark := range valueMarks {
614- if mark == marks .Sensitive {
615- sensitive = true
616- break
617- }
601+
602+ // non-root outputs need to keep sensitive marks for evaluation, but are
603+ // not serialized.
604+ if n .Addr .Module .IsRoot () {
605+ val , _ = val .UnmarkDeep ()
606+ val = cty .UnknownAsNull (val )
618607 }
619608
620- stateVal := cty .UnknownAsNull (unmarkedVal )
621- state .SetOutputValue (n .Addr , stateVal , sensitive )
609+ state .SetOutputValue (n .Addr , val , n .Config .Sensitive )
622610}
0 commit comments