diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 1f7b9c49db..9cd9529300 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -282,6 +282,11 @@ func (m schemaMap) Input( continue } + // Skip things that have a value of some sort already + if _, ok := c.Raw[k]; ok { + continue + } + var value interface{} var err error switch v.Type { diff --git a/helper/schema/schema_test.go b/helper/schema/schema_test.go index 2f8abfac4e..876393a9b8 100644 --- a/helper/schema/schema_test.go +++ b/helper/schema/schema_test.go @@ -1055,10 +1055,6 @@ func TestSchemaMap_Input(t *testing.T) { }, }, - Config: map[string]interface{}{ - "availability_zone": "bar", - }, - Input: map[string]string{ "availability_zone": "foo", }, @@ -1069,9 +1065,36 @@ func TestSchemaMap_Input(t *testing.T) { Err: false, }, + + { + Schema: map[string]*Schema{ + "availability_zone": &Schema{ + Type: TypeString, + Optional: true, + }, + }, + + Config: map[string]interface{}{ + "availability_zone": "bar", + }, + + Input: map[string]string{ + "availability_zone": "foo", + }, + + Result: map[string]interface{}{ + "availability_zone": "bar", + }, + + Err: false, + }, } for i, tc := range cases { + if tc.Config == nil { + tc.Config = make(map[string]interface{}) + } + c, err := config.NewRawConfig(tc.Config) if err != nil { t.Fatalf("err: %s", err)