diff --git a/terraform/context.go b/terraform/context.go index eb12e102d..4c7a6ae0d 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -759,6 +759,11 @@ func (c *Context) planWalkFn(result *Plan) depgraph.WalkFunc { result.init() cb := func(r *Resource) error { + if r.Tainted && r.TaintedIndex > -1 { + // No-op this. We somewhat magically diff this later. + return nil + } + var diff *InstanceDiff is := r.State.Primary @@ -895,7 +900,7 @@ func (c *Context) planDestroyWalkFn(result *Plan) depgraph.WalkFunc { func (c *Context) refreshWalkFn() depgraph.WalkFunc { cb := func(r *Resource) error { is := r.State.Primary - if r.Tainted { + if r.Tainted && r.TaintedIndex > -1 { is = r.State.Tainted[r.TaintedIndex] } diff --git a/terraform/graph.go b/terraform/graph.go index d303fcc81..2a2ad496c 100644 --- a/terraform/graph.go +++ b/terraform/graph.go @@ -271,10 +271,11 @@ func graphAddConfigResources( Type: r.Type, Config: r, Resource: &Resource{ - Id: name, - State: state, - Config: NewResourceConfig(r.RawConfig), - Tainted: len(state.Tainted) > 0, + Id: name, + State: state, + Config: NewResourceConfig(r.RawConfig), + Tainted: len(state.Tainted) > 0, + TaintedIndex: -1, }, }, }