helper/schema: don't mark things computed if an ID is set

This commit is contained in:
Mitchell Hashimoto 2014-08-22 12:18:08 -07:00
parent 9ed601d541
commit eff8306a6c
2 changed files with 29 additions and 3 deletions

View File

@ -401,9 +401,14 @@ func (m schemaMap) diffString(
}
if os == ns {
// They're the same value, return no diff as long as we're not
// computing a new value.
if os != "" || !schema.Computed {
// They're the same value. If there old value is not blank or we
// have an ID, then return right away since we're already setup.
if os != "" || d.Id() != "" {
return nil
}
// Otherwise, only continue if we're computed
if !schema.Computed {
return nil
}
}

View File

@ -76,6 +76,27 @@ func TestSchemaMap_Diff(t *testing.T) {
Err: false,
},
{
Schema: map[string]*Schema{
"availability_zone": &Schema{
Type: TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
},
State: &terraform.ResourceState{
ID: "foo",
},
Config: map[string]interface{}{},
Diff: nil,
Err: false,
},
// String with StateFunc
{
Schema: map[string]*Schema{