diff --git a/helper/schema/schema.go b/helper/schema/schema.go index be5a56aa3..08fbb017f 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -584,6 +584,13 @@ func (m schemaMap) diffMap( // If the new map is nil and we're computed, then ignore it. if n == nil && schema.Computed { + // If we don't have an old value, this whole map is computed + if o == nil { + diff.Attributes[k] = &terraform.ResourceAttrDiff{ + NewComputed: true, + } + } + return nil } diff --git a/helper/schema/schema_test.go b/helper/schema/schema_test.go index 5351f61d7..1b9a01f28 100644 --- a/helper/schema/schema_test.go +++ b/helper/schema/schema_test.go @@ -1292,6 +1292,29 @@ func TestSchemaMap_Diff(t *testing.T) { Err: false, }, + { + Schema: map[string]*Schema{ + "vars": &Schema{ + Type: TypeMap, + Computed: true, + }, + }, + + State: nil, + + Config: nil, + + Diff: &terraform.InstanceDiff{ + Attributes: map[string]*terraform.ResourceAttrDiff{ + "vars": &terraform.ResourceAttrDiff{ + NewComputed: true, + }, + }, + }, + + Err: false, + }, + { Schema: map[string]*Schema{ "config_vars": &Schema{