diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 410bab583..8c2c20674 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -583,6 +583,10 @@ func (m schemaMap) diffMap( return fmt.Errorf("%s: %s", k, err) } + // Delete any count values, since we don't use those + delete(configMap, "#") + delete(stateMap, "#") + // Check if the number of elements has changed. If we're computing // a list and there isn't a config, then it hasn't changed. oldLen, newLen := len(stateMap), len(configMap) diff --git a/helper/schema/schema_test.go b/helper/schema/schema_test.go index f902fa836..fbb402746 100644 --- a/helper/schema/schema_test.go +++ b/helper/schema/schema_test.go @@ -1697,6 +1697,43 @@ func TestSchemaMap_Diff(t *testing.T) { Err: false, }, + + // #44 - Computed maps + { + Schema: map[string]*Schema{ + "vars": &Schema{ + Type: TypeMap, + Computed: true, + }, + }, + + State: &terraform.InstanceState{ + Attributes: map[string]string{ + "vars.#": "0", + }, + }, + + Config: map[string]interface{}{ + "vars": map[string]interface{}{ + "bar": "${var.foo}", + }, + }, + + ConfigVariables: map[string]string{ + "var.foo": config.UnknownVariableValue, + }, + + Diff: &terraform.InstanceDiff{ + Attributes: map[string]*terraform.ResourceAttrDiff{ + "vars.#": &terraform.ResourceAttrDiff{ + Old: "", + NewComputed: true, + }, + }, + }, + + Err: false, + }, } for i, tc := range cases {