From ff4e81cc2be8afa26ab422c0ecc0375872a29550 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Thu, 18 Oct 2018 20:05:33 -0400 Subject: [PATCH] add old values when computing the new InstanceDiff This was previously done in the RequiresNew code, which is skipped in new style provider. --- helper/schema/resource.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/helper/schema/resource.go b/helper/schema/resource.go index 1ed58bfee..7d5a44aa7 100644 --- a/helper/schema/resource.go +++ b/helper/schema/resource.go @@ -320,6 +320,17 @@ func (r *Resource) simpleDiff( return instanceDiff, err } + // Make sure the old value is set in each of the instance diffs. + // This was done by the RequiresNew logic in the full legacy Diff. + for k, attr := range instanceDiff.Attributes { + if attr == nil { + continue + } + if s != nil { + attr.Old = s.Attributes[k] + } + } + if instanceDiff != nil { if err := t.DiffEncode(instanceDiff); err != nil { log.Printf("[ERR] Error encoding timeout to instance diff: %s", err)