helper/resource: Destroy is called if destroy is set on diff

This commit is contained in:
Mitchell Hashimoto 2014-06-24 12:55:59 -07:00
parent 9c024994b7
commit cb591ab2df

View File

@ -23,6 +23,21 @@ func (m *Map) Apply(
return nil, fmt.Errorf("Unknown resource type: %s", s.Type)
}
if d.Destroy {
// If we're destroying a resource that doesn't exist, then we're
// already done.
if s.ID == "" {
return nil, nil
}
// Otherwise call the destroy function
err := r.Destroy(s, meta)
if err == nil {
s = nil
}
return s, err
}
if s.ID == "" {
return r.Create(s, d, meta)
} else {