@@ -97,6 +97,7 @@ func (b *Local) opApply(
9797 // If we weren't given a plan, then we refresh/plan
9898 if op .PlanFile == nil {
9999 // set the policy client to nil for the plan preceding apply
100+ // so that policy evaluation is skipped during the plan.
100101 lr .PlanOpts .PolicyClient = nil
101102 combinedPlanApply = true
102103 // Perform the plan
@@ -114,8 +115,6 @@ func (b *Local) opApply(
114115 if plan != nil && (len (plan .Changes .Resources ) != 0 || len (plan .Changes .Outputs ) != 0 ) {
115116 op .View .Plan (plan , schemas )
116117 }
117- // Report all policy results that may have accumulated during the plan
118- op .View .PolicyResults (plan .PolicyResults )
119118 op .ReportResult (runningOp , diags )
120119 return
121120 }
@@ -427,9 +426,6 @@ func (b *Local) opApply(
427426 var applyState * states.State
428427 var applyDiags tfdiags.Diagnostics
429428
430- // We use a new store for the apply policy results, as objects that failed during the plan policy
431- // evaluation may have updated data which yields a different policy evaluation result.
432- policyResults := plans .NewPolicyResults ()
433429 doneCh := make (chan struct {})
434430 go func () {
435431 defer logging .PanicHandler ()
@@ -438,9 +434,9 @@ func (b *Local) opApply(
438434 log .Printf ("[INFO] backend/local: apply calling Apply" )
439435 applyState , applyDiags = lr .Core .Apply (plan , lr .Config , & terraform.ApplyOpts {
440436 SetVariables : applyTimeValues ,
441- Locks : providerLocksSnapshot (op .DependencyLocks ),
437+ ProviderLocks : providerLocksSnapshot (op .DependencyLocks ),
442438 PolicyClient : lr .PolicyClient ,
443- PolicyResults : policyResults ,
439+ PolicyResults : plan . PolicyResults ,
444440 })
445441 }()
446442
@@ -450,7 +446,7 @@ func (b *Local) opApply(
450446 diags = diags .Append (applyDiags )
451447
452448 // Print the policy results we found during apply
453- op .View .PolicyResults (policyResults )
449+ op .View .PolicyResults (plan . PolicyResults )
454450
455451 // Even on error with an empty state, the state value should not be nil.
456452 // Return early here to prevent corrupting any existing state.
0 commit comments