ignore_changes changing a null map to empty

Fix an error where using `ignore_changes` would cause some null maps to
be saved as an empty map.
This commit is contained in:
James Bardin 2021-11-11 10:15:29 -05:00
parent 64635edfb9
commit 40174b634a
1 changed files with 8 additions and 3 deletions

View File

@ -1289,10 +1289,15 @@ func processIgnoreChangesIndividual(prior, config cty.Value, ignoreChangesPath [
} }
var newVal cty.Value var newVal cty.Value
if len(configMap) == 0 { switch {
newVal = cty.MapValEmpty(v.Type().ElementType()) case len(configMap) > 0:
} else {
newVal = cty.MapVal(configMap) newVal = cty.MapVal(configMap)
case v.IsNull():
// if the config value was null, and no values remain in the map,
// reset the value to null.
newVal = v
default:
newVal = cty.MapValEmpty(v.Type().ElementType())
} }
if len(vMarks) > 0 { if len(vMarks) > 0 {