copy the refreshed state at the end of plan

Otherwise we may end up with the same state value for the state and
refreshState when re-using the context.
This commit is contained in:
James Bardin 2020-09-30 12:13:22 -04:00
parent 8dc6f518c2
commit b464bcbc5d
1 changed files with 4 additions and 2 deletions

View File

@ -562,11 +562,13 @@ The -target option is not for routine use, and is provided only for exceptional
p.Changes = c.changes
c.refreshState.SyncWrapper().RemovePlannedResourceInstanceObjects()
p.State = c.refreshState.DeepCopy()
refreshedState := c.refreshState.DeepCopy()
p.State = refreshedState
// replace the working state with the updated state, so that immediate calls
// to Apply work as expected.
c.state = c.refreshState
c.state = refreshedState
return p, diags
}