diff --git a/plans/objchange/objchange.go b/plans/objchange/objchange.go index 8d28749b4..5870dbf33 100644 --- a/plans/objchange/objchange.go +++ b/plans/objchange/objchange.go @@ -26,9 +26,10 @@ import ( // block where _all_ attributes are computed. func ProposedNewObject(schema *configschema.Block, prior, config cty.Value) cty.Value { if prior.IsNull() { - // This is the easy case... no prior value to merge, so we can just - // return the config as-is. - return config + // In this case, we will treat the prior value as unknown so that + // any computed attributes not overridden in config will show as + // unknown values, rather than null values. + prior = cty.UnknownVal(schema.ImpliedType()) } if config.IsNull() || !config.IsKnown() { // This is a weird situation, but we'll allow it anyway to free diff --git a/plans/objchange/objchange_test.go b/plans/objchange/objchange_test.go index ccab0d4b7..e7b39430b 100644 --- a/plans/objchange/objchange_test.go +++ b/plans/objchange/objchange_test.go @@ -59,7 +59,7 @@ func TestProposedNewObject(t *testing.T) { }), cty.ObjectVal(map[string]cty.Value{ "foo": cty.StringVal("hello"), - "bar": cty.NullVal(cty.String), + "bar": cty.UnknownVal(cty.String), "baz": cty.ObjectVal(map[string]cty.Value{ "boz": cty.StringVal("world"), }), @@ -432,7 +432,7 @@ func TestProposedNewObject(t *testing.T) { }), cty.ObjectVal(map[string]cty.Value{ "bar": cty.StringVal("bosh"), - "baz": cty.NullVal(cty.String), + "baz": cty.UnknownVal(cty.String), }), }), }),