Use full state during updates (#526)

In our existing code, we only use the input state for old and new
properties.  This is incorrect and I'm astonished we've been flying
blind for so long here.  Some resources require the output properties
from the prior operation in order to perform updates.  Interestingly,
we did correclty use the full synthesized state during deletes.

I ran into this with the AWS Cloudfront Distribution resource,
which requires the etag from the prior operation in order to
successfully apply any subsequent operations.
This commit is contained in:
Joe Duffy 2017-11-03 19:45:19 -07:00 committed by GitHub
parent 13b10490c2
commit fbf13ec4d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -284,7 +284,9 @@ func (s *UpdateStep) Apply() (resource.Status, error) {
if err != nil {
return resource.StatusOK, err
}
outs, rst, upderr := prov.Update(s.URN(), s.old.ID, s.old.AllInputs(), s.new.AllInputs())
// Update to the combination of the old "all" state (including outputs), but overwritten with new inputs.
news := s.old.All().Merge(s.new.Inputs)
outs, rst, upderr := prov.Update(s.URN(), s.old.ID, s.old.All(), news)
if upderr != nil {
return rst, upderr
}