Merge pull request #13863 from hashicorp/jbardin/computed-list-requires-new

make sure a computed list is can be RequiresNew
This commit is contained in:
James Bardin 2017-04-21 18:02:14 -04:00 committed by GitHub
commit 9aaf220efb
2 changed files with 47 additions and 0 deletions

View File

@ -744,6 +744,7 @@ func (m schemaMap) diffList(
diff.Attributes[k+".#"] = &terraform.ResourceAttrDiff{ diff.Attributes[k+".#"] = &terraform.ResourceAttrDiff{
Old: oldStr, Old: oldStr,
NewComputed: true, NewComputed: true,
RequiresNew: schema.ForceNew,
} }
return nil return nil
} }

View File

@ -2777,6 +2777,52 @@ func TestSchemaMap_Diff(t *testing.T) {
}, },
}, },
}, },
{
Name: "List with computed schema and ForceNew",
Schema: map[string]*Schema{
"config": &Schema{
Type: TypeList,
Optional: true,
ForceNew: true,
Elem: &Schema{
Type: TypeString,
},
},
},
State: &terraform.InstanceState{
Attributes: map[string]string{
"config.#": "2",
"config.0": "a",
"config.1": "b",
},
},
Config: map[string]interface{}{
"config": []interface{}{"${var.a}", "${var.b}"},
},
ConfigVariables: map[string]ast.Variable{
"var.a": interfaceToVariableSwallowError(
config.UnknownVariableValue),
"var.b": interfaceToVariableSwallowError(
config.UnknownVariableValue),
},
Diff: &terraform.InstanceDiff{
Attributes: map[string]*terraform.ResourceAttrDiff{
"config.#": &terraform.ResourceAttrDiff{
Old: "2",
New: "",
RequiresNew: true,
NewComputed: true,
},
},
},
Err: false,
},
} }
for i, tc := range cases { for i, tc := range cases {