diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 88b35e08f..632672ae0 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -1374,7 +1374,7 @@ func (m schemaMap) validateObject( schema map[string]*Schema, c *terraform.ResourceConfig) ([]string, []error) { raw, _ := c.Get(k) - if _, ok := raw.(map[string]interface{}); !ok { + if _, ok := raw.(map[string]interface{}); !ok && !c.IsComputed(k) { return nil, []error{fmt.Errorf( "%s: expected object, got %s", k, reflect.ValueOf(raw).Kind())} diff --git a/helper/schema/schema_test.go b/helper/schema/schema_test.go index 994c8866a..0a9583aa8 100644 --- a/helper/schema/schema_test.go +++ b/helper/schema/schema_test.go @@ -3974,6 +3974,35 @@ func TestSchemaMap_Validate(t *testing.T) { Err: false, }, + "Good sub-resource, computed value": { + Schema: map[string]*Schema{ + "ingress": &Schema{ + Type: TypeList, + Optional: true, + Elem: &Resource{ + Schema: map[string]*Schema{ + "from": &Schema{ + Type: TypeInt, + Optional: true, + }, + }, + }, + }, + }, + + Config: map[string]interface{}{ + "ingress": []interface{}{ + `${map("from", var.port)}`, + }, + }, + + Vars: map[string]string{ + "var.port": config.UnknownVariableValue, + }, + + Err: false, + }, + "Invalid/unknown field": { Schema: map[string]*Schema{ "availability_zone": &Schema{