From b464bcbc5d98c3294f9d23f5bcfca4ff2ffe2a33 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 30 Sep 2020 12:13:22 -0400 Subject: [PATCH] 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. --- terraform/context.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/terraform/context.go b/terraform/context.go index ccb8941bb..e3f26ef59 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -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 }