diff --git a/terraform/eval_apply.go b/terraform/eval_apply.go index 70b12f388..dd77b8145 100644 --- a/terraform/eval_apply.go +++ b/terraform/eval_apply.go @@ -106,6 +106,39 @@ func (n *EvalApply) Type() EvalType { return EvalTypeNull } +// EvalApplyPost is an EvalNode implementation that does the post-Apply work +type EvalApplyPost struct { + Info *InstanceInfo + State **InstanceState + Error *error +} + +func (n *EvalApplyPost) Args() ([]EvalNode, []EvalType) { + return nil, nil +} + +// TODO: test +func (n *EvalApplyPost) Eval( + ctx EvalContext, args []interface{}) (interface{}, error) { + state := *n.State + + { + // Call post-apply hook + err := ctx.Hook(func(h Hook) (HookAction, error) { + return h.PostApply(n.Info, state, *n.Error) + }) + if err != nil { + return nil, err + } + } + + return nil, *n.Error +} + +func (n *EvalApplyPost) Type() EvalType { + return EvalTypeNull +} + // EvalApplyProvisioners is an EvalNode implementation that executes // the provisioners for a resource. // diff --git a/terraform/transform_resource.go b/terraform/transform_resource.go index 497f2faa3..ffa5e9875 100644 --- a/terraform/transform_resource.go +++ b/terraform/transform_resource.go @@ -290,6 +290,11 @@ func (n *graphNodeExpandedResource) EvalTree() EvalNode { TaintedIndex: -1, TaintedClearPrimary: true, }, + &EvalApplyPost{ + Info: info, + State: &state, + Error: &err, + }, }, }, })