diff --git a/helper/schema/resource_data.go b/helper/schema/resource_data.go index b079dd33ce..c025b24d8e 100644 --- a/helper/schema/resource_data.go +++ b/helper/schema/resource_data.go @@ -304,6 +304,7 @@ func (d *ResourceData) getSet( return d.getList(k, parts, schema, source) } + result.Exists = raw.Exists return result } diff --git a/helper/schema/schema_test.go b/helper/schema/schema_test.go index dc3839e83a..c30e90f61c 100644 --- a/helper/schema/schema_test.go +++ b/helper/schema/schema_test.go @@ -641,6 +641,32 @@ func TestSchemaMap_Diff(t *testing.T) { Err: false, }, + { + Schema: map[string]*Schema{ + "ports": &Schema{ + Type: TypeSet, + Computed: true, + Required: true, + Elem: &Schema{Type: TypeInt}, + Set: func(a interface{}) int { + return a.(int) + }, + }, + }, + + State: &terraform.InstanceState{ + Attributes: map[string]string{ + "ports.#": "0", + }, + }, + + Config: nil, + + Diff: nil, + + Err: false, + }, + { Schema: map[string]*Schema{ "ports": &Schema{