From 009df443f7088f418fc13a5624200976043a9a5b Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 29 Mar 2019 09:36:27 -0400 Subject: [PATCH] restore lost unknowns during a planned update. Because schema.ResourceDiff can't differentiate between unknown values and new computed values, unknowns can be lost during an update. If a planned value converted an unknown to a null, restore the unknown so that it can be correctly replaced in the final plan. --- helper/plugin/grpc_provider.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/helper/plugin/grpc_provider.go b/helper/plugin/grpc_provider.go index c2299b24f2..b268795d8f 100644 --- a/helper/plugin/grpc_provider.go +++ b/helper/plugin/grpc_provider.go @@ -1144,6 +1144,14 @@ func normalizeNullValues(dst, src cty.Value, preferDst bool) cty.Value { ty := dst.Type() if !src.IsNull() && !src.IsKnown() { + // While this seems backwards to return src when preferDst is set, it + // means this might be a plan scenario, and it must retain unknown + // interpolated placeholders, which could be lost if we're only updating + // a resource. If this is a read scenario, then there shouldn't be any + // unknowns all. + if dst.IsNull() && preferDst { + return src + } return dst }