helper/schema: don't mark things computed if an ID is set
This commit is contained in:
parent
9ed601d541
commit
eff8306a6c
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue