diff --git a/terraform/eval_apply.go b/terraform/eval_apply.go index db036945d5..0699738553 100644 --- a/terraform/eval_apply.go +++ b/terraform/eval_apply.go @@ -19,7 +19,6 @@ type EvalApply struct { Output **InstanceState CreateNew *bool Error *error - Tainted *bool } func (n *EvalApply) Args() ([]EvalNode, []EvalType) { @@ -96,11 +95,6 @@ func (n *EvalApply) Eval( *n.Output = state } - // Set the tainted state - if n.Tainted != nil { - *n.Tainted = err != nil - } - // If there are no errors, then we append it to our output error // if we have one, otherwise we just output it. if err != nil { @@ -175,13 +169,23 @@ func (n *EvalApplyProvisioners) Eval( ctx EvalContext, args []interface{}) (interface{}, error) { state := *n.State - if *n.Tainted { - // We're already tainted, so just return out + if !*n.CreateNew { + // If we're not creating a new resource, then don't run provisioners return nil, nil } - if !*n.CreateNew { - // If we're not creating a new resource, then don't run provisioners + if len(n.Resource.Provisioners) == 0 { + // We have no provisioners, so don't do anything + return nil, nil + } + + if n.Error != nil && *n.Error != nil { + // We're already errored creating, so mark as tainted and continue + if n.Tainted != nil { + *n.Tainted = true + } + + // We're already tainted, so just return out return nil, nil } diff --git a/terraform/terraform_test.go b/terraform/terraform_test.go index 412205f849..d6d8a305b2 100644 --- a/terraform/terraform_test.go +++ b/terraform/terraform_test.go @@ -337,9 +337,8 @@ const testTerraformApplyDestroyStr = ` ` const testTerraformApplyErrorStr = ` -aws_instance.bar: (1 tainted) - ID = - Tainted ID 1 = bar +aws_instance.bar: + ID = bar Dependencies: aws_instance.foo @@ -361,9 +360,8 @@ aws_instance.bar: (1 tainted) ` const testTerraformApplyErrorPartialStr = ` -aws_instance.bar: (1 tainted) - ID = - Tainted ID 1 = bar +aws_instance.bar: + ID = bar Dependencies: aws_instance.foo @@ -464,9 +462,10 @@ foo_num = bar ` const testTerraformApplyUnknownAttrStr = ` -aws_instance.foo: (1 tainted) - ID = - Tainted ID 1 = foo +aws_instance.foo: + ID = foo + num = 2 + type = aws_instance ` const testTerraformApplyVarsStr = ` diff --git a/terraform/transform_resource.go b/terraform/transform_resource.go index 27918a8f93..ea5090295e 100644 --- a/terraform/transform_resource.go +++ b/terraform/transform_resource.go @@ -287,7 +287,6 @@ func (n *graphNodeExpandedResource) EvalTree() EvalNode { Output: &state, Error: &err, CreateNew: &createNew, - Tainted: &tainted, }, &EvalWriteState{ Name: n.stateId(),