diff --git a/helper/schema/schema.go b/helper/schema/schema.go index 3650123d3..6b0afa6b2 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -346,7 +346,7 @@ func (m schemaMap) Input( "%s: %s", k, err) } - c.Raw[k] = value + c.Config[k] = value } return c, nil diff --git a/helper/schema/schema_test.go b/helper/schema/schema_test.go index 8a06d2c48..ea71351ef 100644 --- a/helper/schema/schema_test.go +++ b/helper/schema/schema_test.go @@ -1413,9 +1413,7 @@ func TestSchemaMap_Input(t *testing.T) { "availability_zone": "foo", }, - Result: map[string]interface{}{ - "availability_zone": "bar", - }, + Result: map[string]interface{}{}, Err: false, }, @@ -1494,14 +1492,16 @@ func TestSchemaMap_Input(t *testing.T) { input := new(terraform.MockUIInput) input.InputReturnMap = tc.Input - actual, err := schemaMap(tc.Schema).Input( - input, terraform.NewResourceConfig(c)) + rc := terraform.NewResourceConfig(c) + rc.Config = make(map[string]interface{}) + + actual, err := schemaMap(tc.Schema).Input(input, rc) if (err != nil) != tc.Err { t.Fatalf("#%d err: %s", i, err) } - if !reflect.DeepEqual(tc.Result, actual.Raw) { - t.Fatalf("#%d: bad:\n\n%#v", i, actual.Raw) + if !reflect.DeepEqual(tc.Result, actual.Config) { + t.Fatalf("#%d: bad:\n\n%#v", i, actual.Config) } } } diff --git a/terraform/context.go b/terraform/context.go index c6f367fb5..29f9c1c73 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -600,6 +600,7 @@ func (c *walkContext) inputWalkFn() depgraph.WalkFunc { raw = sharedProvider.Config.RawConfig } rc := NewResourceConfig(raw) + rc.Config = make(map[string]interface{}) // Wrap the input into a namespace input := &PrefixUIInput{ @@ -617,8 +618,8 @@ func (c *walkContext) inputWalkFn() depgraph.WalkFunc { return fmt.Errorf( "Error configuring %s: %s", k, err) } - if newc != nil { - configs[k] = newc.Raw + if newc != nil && len(newc.Config) > 0 { + configs[k] = newc.Config } } diff --git a/terraform/context_test.go b/terraform/context_test.go index 0c3a0a83e..9dc34c07e 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -647,11 +647,11 @@ func TestContextInput_provider(t *testing.T) { var actual interface{} p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) { - c.Raw["foo"] = "bar" + c.Config["foo"] = "bar" return c, nil } p.ConfigureFn = func(c *ResourceConfig) error { - actual = c.Raw["foo"] + actual = c.Config["foo"] return nil } @@ -693,11 +693,11 @@ func TestContextInput_providerId(t *testing.T) { return nil, err } - c.Raw["foo"] = v + c.Config["foo"] = v return c, nil } p.ConfigureFn = func(c *ResourceConfig) error { - actual = c.Raw["foo"] + actual = c.Config["foo"] return nil } @@ -745,11 +745,11 @@ func TestContextInput_providerOnly(t *testing.T) { var actual interface{} p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) { - c.Raw["foo"] = "bar" + c.Config["foo"] = "bar" return c, nil } p.ConfigureFn = func(c *ResourceConfig) error { - actual = c.Raw["foo"] + actual = c.Config["foo"] return nil } @@ -794,10 +794,13 @@ func TestContextInput_providerVars(t *testing.T) { UIInput: input, }) - input.InputReturnMap = map[string]string{} + input.InputReturnMap = map[string]string{ + "var.foo": "bar", + } var actual interface{} p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) { + c.Config["bar"] = "baz" return c, nil } p.ConfigureFn = func(c *ResourceConfig) error { diff --git a/terraform/graph.go b/terraform/graph.go index b52dacdd1..0e561c882 100644 --- a/terraform/graph.go +++ b/terraform/graph.go @@ -1594,14 +1594,15 @@ func graphRemoveInvalidDeps(g *depgraph.Graph) { func (p *graphSharedProvider) MergeConfig( raw bool, override map[string]interface{}) *ResourceConfig { var rawMap map[string]interface{} - if override != nil { - rawMap = override - } else if p.Config != nil { + if p.Config != nil { rawMap = p.Config.RawConfig.Config() } if rawMap == nil { rawMap = make(map[string]interface{}) } + for k, v := range override { + rawMap[k] = v + } // Merge in all the parent configurations if p.Parent != nil {