diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 3650123d36..6905325288 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -580,6 +580,11 @@ func (m schemaMap) diffMap( return fmt.Errorf("%s: %s", k, err) } + // If the new map is nil and we're computed, then ignore it. + if n == nil && schema.Computed { + return nil + } + // Now we compare, preferring values from the config map for k, v := range configMap { old := stateMap[k] diff --git a/helper/schema/schema_test.go b/helper/schema/schema_test.go index 70388f5690..d5ee09a6c5 100644 --- a/helper/schema/schema_test.go +++ b/helper/schema/schema_test.go @@ -1191,6 +1191,27 @@ func TestSchemaMap_Diff(t *testing.T) { Err: false, }, + { + Schema: map[string]*Schema{ + "vars": &Schema{ + Type: TypeMap, + Computed: true, + }, + }, + + State: &terraform.InstanceState{ + Attributes: map[string]string{ + "vars.foo": "bar", + }, + }, + + Config: nil, + + Diff: nil, + + Err: false, + }, + { Schema: map[string]*Schema{ "config_vars": &Schema{