@@ -84,6 +84,10 @@ func (e *executor) execWriteOutput(ctx, killCtx context.Context, args, env []str
84
84
cmd .Stdout = syncWriter {mut , stdOutWriter }
85
85
cmd .Stderr = syncWriter {mut , stdErrWriter }
86
86
87
+ e .server .logger .Debug (ctx , "executing terraform command" ,
88
+ slog .F ("binary_path" , e .binaryPath ),
89
+ slog .F ("args" , args ),
90
+ )
87
91
err = cmd .Start ()
88
92
if err != nil {
89
93
return err
@@ -260,6 +264,20 @@ func (e *executor) plan(ctx, killCtx context.Context, env, vars []string, logr l
260
264
}, nil
261
265
}
262
266
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
+
263
281
// planResources must only be called while the lock is held.
264
282
func (e * executor ) planResources (ctx , killCtx context.Context , planfilePath string ) (* State , error ) {
265
283
ctx , span := e .server .startTrace (ctx , tracing .FuncName ())
@@ -276,7 +294,16 @@ func (e *executor) planResources(ctx, killCtx context.Context, planfilePath stri
276
294
}
277
295
modules := []* tfjson.StateModule {}
278
296
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
+ )
280
307
}
281
308
modules = append (modules , plan .PlannedValues .RootModule )
282
309
0 commit comments