always re-read datasource if there are dep changes
If a datasource's dependencies have planned changes, then we need to plan a read for the data source, because the config may change once the dependencies have been applied.
This commit is contained in:
parent
f9dfa98533
commit
35e087fe5b
|
@ -81,8 +81,31 @@ func (n *NodePlannableResourceInstance) evalTreeDataResource(addr addrs.AbsResou
|
|||
// here.
|
||||
&EvalIf{
|
||||
If: func(ctx EvalContext) (bool, error) {
|
||||
if state != nil && state.Status != states.ObjectPlanned {
|
||||
return true, EvalEarlyExitError{}
|
||||
depChanges := false
|
||||
|
||||
// Check and see if any of our dependencies have changes.
|
||||
changes := ctx.Changes()
|
||||
for _, d := range n.StateReferences() {
|
||||
ri, ok := d.(addrs.ResourceInstance)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
change := changes.GetResourceInstanceChange(ri.Absolute(ctx.Path()), states.CurrentGen)
|
||||
if change != nil && change.Action != plans.NoOp {
|
||||
depChanges = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
refreshed := state != nil && state.Status != states.ObjectPlanned
|
||||
|
||||
// If there are no dependency changes, and it's not a forced
|
||||
// read because we there was no Refresh, then we don't need
|
||||
// to re-read. If any dependencies have changes, it means
|
||||
// our config may also have changes and we need to Read the
|
||||
// data source again.
|
||||
if !depChanges && refreshed {
|
||||
return false, EvalEarlyExitError{}
|
||||
}
|
||||
return true, nil
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue