diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 712720fcd..5c0a238ce 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -169,6 +169,15 @@ func (m schemaMap) diffList( } case *Resource: // This is a complex resource + for i, _ := range vs { + for k2, schema := range t.Schema { + subK := fmt.Sprintf("%s.%d.%s", k, i, k2) + err := m.diff(subK, schema, diff, s, c) + if err != nil { + return err + } + } + } default: return fmt.Errorf("%s: unknown element type (internal)", k) } diff --git a/helper/schema/schema_test.go b/helper/schema/schema_test.go index 911c853f4..3ad537df2 100644 --- a/helper/schema/schema_test.go +++ b/helper/schema/schema_test.go @@ -309,6 +309,52 @@ func TestSchemaMap_Diff(t *testing.T) { Err: false, }, + + /* + * List of structure decode + */ + + { + Schema: map[string]*Schema{ + "ingress": &Schema{ + Type: TypeList, + Required: true, + Elem: &Resource{ + Schema: map[string]*Schema{ + "from": &Schema{ + Type: TypeInt, + Required: true, + }, + }, + }, + }, + }, + + State: nil, + + Config: map[string]interface{}{ + "ingress": []interface{}{ + map[string]interface{}{ + "from": 8080, + }, + }, + }, + + Diff: &terraform.ResourceDiff{ + Attributes: map[string]*terraform.ResourceAttrDiff{ + "ingress.#": &terraform.ResourceAttrDiff{ + Old: "", + New: "1", + }, + "ingress.0.from": &terraform.ResourceAttrDiff{ + Old: "", + New: "8080", + }, + }, + }, + + Err: false, + }, } for i, tc := range cases {