@@ -84,6 +84,10 @@ func (e *executor) execWriteOutput(ctx, killCtx context.Context, args, env []str
8484 cmd .Stdout = syncWriter {mut , stdOutWriter }
8585 cmd .Stderr = syncWriter {mut , stdErrWriter }
8686
87+ e .server .logger .Debug (ctx , "executing terraform command" ,
88+ slog .F ("binary_path" , e .binaryPath ),
89+ slog .F ("args" , args ),
90+ )
8791 err = cmd .Start ()
8892 if err != nil {
8993 return err
@@ -260,6 +264,20 @@ func (e *executor) plan(ctx, killCtx context.Context, env, vars []string, logr l
260264 }, nil
261265}
262266
267+ func onlyDataResources (sm * tfjson.StateModule ) * tfjson.StateModule {
268+ sm2 := * sm
269+ sm2 .Resources = make ([]* tfjson.StateResource , 0 , len (sm .Resources ))
270+ for _ , r := range sm .Resources {
271+ if r .Mode == "data" {
272+ sm2 .Resources = append (sm2 .Resources , r )
273+ }
274+ }
275+ for _ , c := range sm .ChildModules {
276+ sm2 .ChildModules = append (sm2 .ChildModules , onlyDataResources (c ))
277+ }
278+ return & sm2
279+ }
280+
263281// planResources must only be called while the lock is held.
264282func (e * executor ) planResources (ctx , killCtx context.Context , planfilePath string ) (* State , error ) {
265283 ctx , span := e .server .startTrace (ctx , tracing .FuncName ())
@@ -276,7 +294,16 @@ func (e *executor) planResources(ctx, killCtx context.Context, planfilePath stri
276294 }
277295 modules := []* tfjson.StateModule {}
278296 if plan .PriorState != nil {
279- modules = append (modules , plan .PriorState .Values .RootModule )
297+ // We need the data resources for rich parameters. For some reason, they
298+ // only show up in the PriorState.
299+ //
300+ // We don't want all prior resources, because Quotas (and
301+ // future features) would never know which resources are getting
302+ // deleted by a stop.
303+ modules = append (
304+ modules ,
305+ onlyDataResources (plan .PriorState .Values .RootModule ),
306+ )
280307 }
281308 modules = append (modules , plan .PlannedValues .RootModule )
282309
0 commit comments