diff --git a/terraform/context_test.go b/terraform/context_test.go index e880bb499..ccd304eb9 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -3424,8 +3424,7 @@ func TestContext2Apply_provisionerFail_createBeforeDestroy(t *testing.T) { } } -/* -func TestContextApply_error_createBeforeDestroy(t *testing.T) { +func TestContext2Apply_error_createBeforeDestroy(t *testing.T) { m := testModule(t, "apply-error-create-before") p := testProvider("aws") state := &State{ @@ -3446,7 +3445,7 @@ func TestContextApply_error_createBeforeDestroy(t *testing.T) { }, }, } - ctx := testContext(t, &ContextOpts{ + ctx := testContext2(t, &ContextOpts{ Module: m, Providers: map[string]ResourceProviderFactory{ "aws": testProviderFuncFixed(p), @@ -3470,10 +3469,11 @@ func TestContextApply_error_createBeforeDestroy(t *testing.T) { actual := strings.TrimSpace(state.String()) expected := strings.TrimSpace(testTerraformApplyErrorCreateBeforeDestroyStr) if actual != expected { - t.Fatalf("bad: \n%s\n\n\n%s", actual, expected) + t.Fatalf("bad: \n%s\n\nExpected:\n\n%s", actual, expected) } } +/* func TestContextApply_errorDestroy_createBeforeDestroy(t *testing.T) { m := testModule(t, "apply-error-create-before") p := testProvider("aws") diff --git a/terraform/eval_state.go b/terraform/eval_state.go index 93225e2f9..cf315dade 100644 --- a/terraform/eval_state.go +++ b/terraform/eval_state.go @@ -103,6 +103,8 @@ func (n *EvalWriteState) Eval( rs.Type = n.ResourceType rs.Dependencies = n.Dependencies + println(fmt.Sprintf("%#v", rs)) + println(fmt.Sprintf("%#v", *n.State)) if n.Tainted != nil && *n.Tainted { if n.TaintedIndex != -1 { rs.Tainted[n.TaintedIndex] = *n.State diff --git a/terraform/transform_resource.go b/terraform/transform_resource.go index 940a53fa1..dfa06b913 100644 --- a/terraform/transform_resource.go +++ b/terraform/transform_resource.go @@ -315,8 +315,9 @@ func (n *graphNodeExpandedResource) EvalTree() EvalNode { }, &EvalIf{ If: func(ctx EvalContext) (bool, error) { - return n.Resource.Lifecycle.CreateBeforeDestroy && - tainted, nil + failure := tainted || err != nil + tainted = n.Resource.Lifecycle.CreateBeforeDestroy + return n.Resource.Lifecycle.CreateBeforeDestroy && failure, nil }, Node: &EvalUndeposeState{ Name: n.stateId(),