-
Notifications
You must be signed in to change notification settings - Fork 9.4k
/
planned_change.go
592 lines (515 loc) · 21 KB
/
planned_change.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package stackplan
import (
"fmt"
"time"
"github.com/hashicorp/go-version"
"github.com/zclconf/go-cty/cty"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
"github.com/hashicorp/terraform/internal/addrs"
"github.com/hashicorp/terraform/internal/collections"
"github.com/hashicorp/terraform/internal/configs/configschema"
"github.com/hashicorp/terraform/internal/plans"
"github.com/hashicorp/terraform/internal/plans/planfile"
"github.com/hashicorp/terraform/internal/plans/planproto"
"github.com/hashicorp/terraform/internal/providers"
"github.com/hashicorp/terraform/internal/rpcapi/terraform1"
"github.com/hashicorp/terraform/internal/stacks/stackaddrs"
"github.com/hashicorp/terraform/internal/stacks/stackutils"
"github.com/hashicorp/terraform/internal/stacks/tfstackdata1"
"github.com/hashicorp/terraform/internal/states"
)
// PlannedChange represents a single isolated planned changed, emitted as
// part of a stream of planned changes during the PlanStackChanges RPC API
// operation.
//
// Each PlannedChange becomes a single event in the RPC API, which itself
// has zero or more opaque raw plan messages that the caller must collect and
// provide verbatim during planning and zero or one "description" messages
// that are to give the caller realtime updates about the planning process.
//
// The aggregated sequence of "raw" messages can be provided later to
// [LoadFromProto] to obtain a [Plan] object containing the information
// Terraform Core would need to apply the plan.
type PlannedChange interface {
// PlannedChangeProto returns the protocol buffers representation of
// the change, ready to be sent verbatim to an RPC API client.
PlannedChangeProto() (*terraform1.PlannedChange, error)
}
// PlannedChangeRootInputValue announces the existence of a root stack input
// variable and captures its plan-time value so we can make sure to use
// the same value during the apply phase.
type PlannedChangeRootInputValue struct {
Addr stackaddrs.InputVariable
// Value is the value we used for the variable during planning.
Value cty.Value
}
var _ PlannedChange = (*PlannedChangeRootInputValue)(nil)
// PlannedChangeProto implements PlannedChange.
func (pc *PlannedChangeRootInputValue) PlannedChangeProto() (*terraform1.PlannedChange, error) {
// We use cty.DynamicPseudoType here so that we'll save both the
// value _and_ its dynamic type in the plan, so we can recover
// exactly the same value later.
dv, err := plans.NewDynamicValue(pc.Value, cty.DynamicPseudoType)
if err != nil {
return nil, fmt.Errorf("can't encode value for %s: %w", pc.Addr, err)
}
var raw anypb.Any
err = anypb.MarshalFrom(&raw, &tfstackdata1.PlanRootInputValue{
Name: pc.Addr.Name,
Value: &planproto.DynamicValue{
Msgpack: dv,
},
}, proto.MarshalOptions{})
if err != nil {
return nil, err
}
return &terraform1.PlannedChange{
Raw: []*anypb.Any{&raw},
// There is no external-facing description for this change type.
}, nil
}
// PlannedChangeComponentInstance announces the existence of a component
// instance and describes (using a plan action) whether it is being added
// or removed.
type PlannedChangeComponentInstance struct {
Addr stackaddrs.AbsComponentInstance
// PlanApplyable is true if the modules runtime ruled that this particular
// component's plan is applyable.
//
// See the documentation for [plans.Plan.Applyable] for details on what
// exactly this represents.
PlanApplyable bool
// PlanApplyable is true if the modules runtime ruled that this particular
// component's plan is complete.
//
// See the documentation for [plans.Plan.Complete] for details on what
// exactly this represents.
PlanComplete bool
// Action describes any difference in the existence of this component
// instance compared to the prior state.
//
// Currently it can only be "Create", "Delete", or "NoOp". This action
// relates to the existence of the component instance itself and does
// not consider the resource instances inside, whose change actions
// are tracked in their own [PlannedChange] objects.
Action plans.Action
// RequiredComponents is a set of the addresses of all of the components
// that provide infrastructure that this one's infrastructure will
// depend on. Any component named here must exist for the entire lifespan
// of this component instance.
RequiredComponents collections.Set[stackaddrs.AbsComponent]
// PlannedInputValues records our best approximation of the component's
// topmost input values during the planning phase. This could contain
// unknown values if one component is configured from results of another.
// This therefore won't be used directly as the input values during apply,
// but the final set of input values during apply should be consistent
// with what's captured here.
PlannedInputValues map[string]plans.DynamicValue
PlannedInputValueMarks map[string][]cty.PathValueMarks
PlannedOutputValues map[string]cty.Value
PlannedCheckResults *states.CheckResults
// PlanTimestamp is the timestamp that would be returned from the
// "plantimestamp" function in modules inside this component. We
// must preserve this in the raw plan data to ensure that we can
// return the same timestamp again during the apply phase.
PlanTimestamp time.Time
}
var _ PlannedChange = (*PlannedChangeComponentInstance)(nil)
// PlannedChangeProto implements PlannedChange.
func (pc *PlannedChangeComponentInstance) PlannedChangeProto() (*terraform1.PlannedChange, error) {
var plannedInputValues map[string]*tfstackdata1.DynamicValue
if n := len(pc.PlannedInputValues); n != 0 {
plannedInputValues = make(map[string]*tfstackdata1.DynamicValue, n)
for k, v := range pc.PlannedInputValues {
var sensitivePaths []*planproto.Path
if pvm, ok := pc.PlannedInputValueMarks[k]; ok {
for _, p := range pvm {
path, err := planproto.NewPath(p.Path)
if err != nil {
return nil, err
}
sensitivePaths = append(sensitivePaths, path)
}
}
plannedInputValues[k] = &tfstackdata1.DynamicValue{
Value: &planproto.DynamicValue{
Msgpack: v,
},
SensitivePaths: sensitivePaths,
}
}
}
var planTimestampStr string
var zeroTime time.Time
if pc.PlanTimestamp != zeroTime {
planTimestampStr = pc.PlanTimestamp.Format(time.RFC3339)
}
componentAddrsRaw := make([]string, 0, pc.RequiredComponents.Len())
for _, componentAddr := range pc.RequiredComponents.Elems() {
componentAddrsRaw = append(componentAddrsRaw, componentAddr.String())
}
plannedOutputValues := make(map[string]*tfstackdata1.DynamicValue)
for k, v := range pc.PlannedOutputValues {
dv, err := tfstackdata1.DynamicValueToTFStackData1(v, cty.DynamicPseudoType)
if err != nil {
return nil, fmt.Errorf("encoding output value %q: %w", k, err)
}
plannedOutputValues[k] = dv
}
plannedCheckResults, err := planfile.CheckResultsToPlanProto(pc.PlannedCheckResults)
if err != nil {
return nil, fmt.Errorf("failed to encode check results: %s", err)
}
var raw anypb.Any
err = anypb.MarshalFrom(&raw, &tfstackdata1.PlanComponentInstance{
ComponentInstanceAddr: pc.Addr.String(),
PlanTimestamp: planTimestampStr,
PlannedInputValues: plannedInputValues,
PlannedAction: planproto.NewAction(pc.Action),
PlanApplyable: pc.PlanApplyable,
PlanComplete: pc.PlanComplete,
DependsOnComponentAddrs: componentAddrsRaw,
PlannedOutputValues: plannedOutputValues,
PlannedCheckResults: plannedCheckResults,
}, proto.MarshalOptions{})
if err != nil {
return nil, err
}
protoChangeTypes, err := terraform1.ChangeTypesForPlanAction(pc.Action)
if err != nil {
return nil, err
}
return &terraform1.PlannedChange{
Raw: []*anypb.Any{&raw},
Descriptions: []*terraform1.PlannedChange_ChangeDescription{
{
Description: &terraform1.PlannedChange_ChangeDescription_ComponentInstancePlanned{
ComponentInstancePlanned: &terraform1.PlannedChange_ComponentInstance{
Addr: &terraform1.ComponentInstanceInStackAddr{
ComponentAddr: stackaddrs.ConfigComponentForAbsInstance(pc.Addr).String(),
ComponentInstanceAddr: pc.Addr.String(),
},
Actions: protoChangeTypes,
PlanComplete: pc.PlanComplete,
// We don't include "applyable" in here since for a
// stack operation it's the overall stack plan applyable
// flag that matters, and the per-component flags
// are just an implementation detail.
},
},
},
},
}, nil
}
// PlannedChangeResourceInstancePlanned announces an action that Terraform
// is proposing to take if this plan is applied.
type PlannedChangeResourceInstancePlanned struct {
ResourceInstanceObjectAddr stackaddrs.AbsResourceInstanceObject
// ChangeSrc describes the planned change, if any. This can be nil if
// we're only intending to update the state to match PriorStateSrc.
ChangeSrc *plans.ResourceInstanceChangeSrc
// PriorStateSrc describes the "prior state" that the planned change, if
// any, was generated against.
//
// This can be nil if the object didn't previously exist. If both
// PriorStateSrc and ChangeSrc are nil then that suggests that the
// object existed in the previous run's state but was found to no
// longer exist while refreshing during plan.
PriorStateSrc *states.ResourceInstanceObjectSrc
// ProviderConfigAddr is the address of the provider configuration
// that planned this change, resolved in terms of the configuration for
// the component this resource instance object belongs to.
ProviderConfigAddr addrs.AbsProviderConfig
// Schema MUST be the same schema that was used to encode the dynamic
// values inside ChangeSrc and PriorStateSrc.
//
// Can be nil if and only if ChangeSrc and PriorStateSrc are both nil
// themselves.
Schema *configschema.Block
}
var _ PlannedChange = (*PlannedChangeResourceInstancePlanned)(nil)
func (pc *PlannedChangeResourceInstancePlanned) PlanResourceInstanceChangePlannedProto() (*tfstackdata1.PlanResourceInstanceChangePlanned, error) {
rioAddr := pc.ResourceInstanceObjectAddr
if pc.ChangeSrc == nil && pc.PriorStateSrc == nil {
// This is just a stubby placeholder to remind us to drop the
// apparently-deleted-outside-of-Terraform object from the state
// if this plan later gets applied.
// We only emit a "raw" in this case, because this is a relatively
// uninteresting edge-case.
return &tfstackdata1.PlanResourceInstanceChangePlanned{
ComponentInstanceAddr: rioAddr.Component.String(),
ResourceInstanceAddr: rioAddr.Item.ResourceInstance.String(),
DeposedKey: rioAddr.Item.DeposedKey.String(),
ProviderConfigAddr: pc.ProviderConfigAddr.String(),
}, nil
}
// We include the prior state as part of the raw plan because that
// contains the result of upgrading the state to the provider's latest
// schema version and incorporating any changes detected in the refresh
// step, which we'll rely on during the apply step to make sure that
// the final plan is consistent, etc.
priorStateProto := tfstackdata1.ResourceInstanceObjectStateToTFStackData1(pc.PriorStateSrc, pc.ProviderConfigAddr)
changeProto, err := planfile.ResourceChangeToProto(pc.ChangeSrc)
if err != nil {
return nil, fmt.Errorf("converting resource instance change to proto: %w", err)
}
return &tfstackdata1.PlanResourceInstanceChangePlanned{
ComponentInstanceAddr: rioAddr.Component.String(),
ResourceInstanceAddr: rioAddr.Item.ResourceInstance.String(),
DeposedKey: rioAddr.Item.DeposedKey.String(),
ProviderConfigAddr: pc.ProviderConfigAddr.String(),
Change: changeProto,
PriorState: priorStateProto,
}, nil
}
func (pc *PlannedChangeResourceInstancePlanned) ChangeDesciption() (*terraform1.PlannedChange_ChangeDescription, error) {
rioAddr := pc.ResourceInstanceObjectAddr
// We only emit an external description if there's a change to describe.
// Otherwise, we just emit a raw to remind us to update the state for
// this object during the apply step, to match the prior state.
if pc.ChangeSrc == nil {
return nil, nil
}
protoChangeTypes, err := terraform1.ChangeTypesForPlanAction(pc.ChangeSrc.Action)
if err != nil {
return nil, err
}
replacePaths, err := encodePathSet(pc.ChangeSrc.RequiredReplace)
if err != nil {
return nil, err
}
return &terraform1.PlannedChange_ChangeDescription{
Description: &terraform1.PlannedChange_ChangeDescription_ResourceInstancePlanned{
ResourceInstancePlanned: &terraform1.PlannedChange_ResourceInstance{
Addr: terraform1.NewResourceInstanceObjectInStackAddr(rioAddr),
ResourceMode: stackutils.ResourceModeForProto(pc.ChangeSrc.Addr.Resource.Resource.Mode),
ResourceType: pc.ChangeSrc.Addr.Resource.Resource.Type,
ProviderAddr: pc.ChangeSrc.ProviderAddr.Provider.String(),
Actions: protoChangeTypes,
Values: &terraform1.DynamicValueChange{
Old: terraform1.NewDynamicValue(
pc.ChangeSrc.Before,
pc.ChangeSrc.BeforeSensitivePaths,
),
New: terraform1.NewDynamicValue(
pc.ChangeSrc.After,
pc.ChangeSrc.AfterSensitivePaths,
),
},
ReplacePaths: replacePaths,
// TODO: Moved, Imported
},
},
}, nil
}
// PlannedChangeProto implements PlannedChange.
func (pc *PlannedChangeResourceInstancePlanned) PlannedChangeProto() (*terraform1.PlannedChange, error) {
pric, err := pc.PlanResourceInstanceChangePlannedProto()
if err != nil {
return nil, err
}
var raw anypb.Any
err = anypb.MarshalFrom(&raw, pric, proto.MarshalOptions{})
if err != nil {
return nil, err
}
if pc.ChangeSrc == nil && pc.PriorStateSrc == nil {
// This is just a stubby placeholder to remind us to drop the
// apparently-deleted-outside-of-Terraform object from the state
// if this plan later gets applied.
// We only emit a "raw" in this case, because this is a relatively
// uninteresting edge-case.
return &terraform1.PlannedChange{
Raw: []*anypb.Any{&raw},
}, nil
}
var descs []*terraform1.PlannedChange_ChangeDescription
desc, err := pc.ChangeDesciption()
if err != nil {
return nil, err
}
if desc != nil {
descs = append(descs, desc)
}
return &terraform1.PlannedChange{
Raw: []*anypb.Any{&raw},
Descriptions: descs,
}, nil
}
// PlannedChangeDeferredResourceInstancePlanned announces that an action that Terraform
// is proposing to take if this plan is applied is being deferred.
type PlannedChangeDeferredResourceInstancePlanned struct {
// ResourceInstancePlanned is the planned change that is being deferred.
ResourceInstancePlanned PlannedChangeResourceInstancePlanned
// DeferredReason is the reason why the change is being deferred.
DeferredReason providers.DeferredReason
}
var _ PlannedChange = (*PlannedChangeDeferredResourceInstancePlanned)(nil)
// PlannedChangeProto implements PlannedChange.
func (dpc *PlannedChangeDeferredResourceInstancePlanned) PlannedChangeProto() (*terraform1.PlannedChange, error) {
change, err := dpc.ResourceInstancePlanned.PlanResourceInstanceChangePlannedProto()
if err != nil {
return nil, err
}
var deferred tfstackdata1.PlanDeferredResourceInstanceChange_Deferred
switch dpc.DeferredReason {
case providers.DeferredReasonInstanceCountUnknown:
deferred.Reason = tfstackdata1.PlanDeferredResourceInstanceChange_Deferred_INSTANCE_COUNT_UNKNOWN
case providers.DeferredReasonResourceConfigUnknown:
deferred.Reason = tfstackdata1.PlanDeferredResourceInstanceChange_Deferred_RESOURCE_CONFIG_UNKNOWN
case providers.DeferredReasonProviderConfigUnknown:
deferred.Reason = tfstackdata1.PlanDeferredResourceInstanceChange_Deferred_PROVIDER_CONFIG_UNKNOWN
case providers.DeferredReasonAbsentPrereq:
deferred.Reason = tfstackdata1.PlanDeferredResourceInstanceChange_Deferred_ABSENT_PREREQ
case providers.DeferredReasonDeferredPrereq:
deferred.Reason = tfstackdata1.PlanDeferredResourceInstanceChange_Deferred_DEFERRED_PREREQ
default:
deferred.Reason = tfstackdata1.PlanDeferredResourceInstanceChange_Deferred_INVALID
}
var raw anypb.Any
err = anypb.MarshalFrom(&raw, &tfstackdata1.PlanDeferredResourceInstanceChange{
Change: change,
Deferred: &deferred,
}, proto.MarshalOptions{})
if err != nil {
return nil, err
}
ricd, err := dpc.ResourceInstancePlanned.ChangeDesciption()
if err != nil {
return nil, err
}
var deferred2 terraform1.Deferred
switch dpc.DeferredReason {
case providers.DeferredReasonInstanceCountUnknown:
deferred2.Reason = terraform1.Deferred_INSTANCE_COUNT_UNKNOWN
case providers.DeferredReasonResourceConfigUnknown:
deferred2.Reason = terraform1.Deferred_RESOURCE_CONFIG_UNKNOWN
case providers.DeferredReasonProviderConfigUnknown:
deferred2.Reason = terraform1.Deferred_PROVIDER_CONFIG_UNKNOWN
case providers.DeferredReasonAbsentPrereq:
deferred2.Reason = terraform1.Deferred_ABSENT_PREREQ
case providers.DeferredReasonDeferredPrereq:
deferred2.Reason = terraform1.Deferred_DEFERRED_PREREQ
default:
deferred2.Reason = terraform1.Deferred_INVALID
}
var descs []*terraform1.PlannedChange_ChangeDescription
descs = append(descs, &terraform1.PlannedChange_ChangeDescription{
Description: &terraform1.PlannedChange_ChangeDescription_ResourceInstanceDeferred{
ResourceInstanceDeferred: &terraform1.PlannedChange_ResourceInstanceDeferred{
ResourceInstance: ricd.GetResourceInstancePlanned(),
Deferred: &deferred2,
},
},
})
return &terraform1.PlannedChange{
Raw: []*anypb.Any{&raw},
Descriptions: descs,
}, nil
}
func encodePathSet(pathSet cty.PathSet) ([]*terraform1.AttributePath, error) {
if pathSet.Empty() {
return nil, nil
}
pathList := pathSet.List()
paths := make([]*terraform1.AttributePath, 0, len(pathList))
for _, path := range pathList {
paths = append(paths, terraform1.NewAttributePath(path))
}
return paths, nil
}
// PlannedChangeOutputValue announces the change action for one output value
// declared in the top-level stack configuration.
//
// This change type only includes an external description, and does not
// contribute anything to the raw plan sequence.
type PlannedChangeOutputValue struct {
Addr stackaddrs.OutputValue // Covers only root stack output values
Action plans.Action
OldValue, NewValue plans.DynamicValue
OldValueSensitivePaths, NewValueSensitivePaths []cty.Path
}
var _ PlannedChange = (*PlannedChangeOutputValue)(nil)
// PlannedChangeProto implements PlannedChange.
func (pc *PlannedChangeOutputValue) PlannedChangeProto() (*terraform1.PlannedChange, error) {
protoChangeTypes, err := terraform1.ChangeTypesForPlanAction(pc.Action)
if err != nil {
return nil, err
}
return &terraform1.PlannedChange{
// No "raw" representation for output values; we emit them only for
// external consumption, since Terraform Core will just recalculate
// them during apply anyway.
Descriptions: []*terraform1.PlannedChange_ChangeDescription{
{
Description: &terraform1.PlannedChange_ChangeDescription_OutputValuePlanned{
OutputValuePlanned: &terraform1.PlannedChange_OutputValue{
Name: pc.Addr.Name,
Actions: protoChangeTypes,
Values: &terraform1.DynamicValueChange{
Old: terraform1.NewDynamicValue(pc.OldValue, pc.OldValueSensitivePaths),
New: terraform1.NewDynamicValue(pc.NewValue, pc.NewValueSensitivePaths),
},
},
},
},
},
}, nil
}
// PlannedChangeHeader is a special change type we typically emit before any
// others to capture overall metadata about a plan. [LoadFromProto] fails if
// asked to decode a plan sequence that doesn't include at least one raw
// message generated from this change type.
//
// PlannedChangeHeader has only a raw message and does not contribute to
// the external-facing plan description.
type PlannedChangeHeader struct {
TerraformVersion *version.Version
PrevRunStateRaw map[string]*anypb.Any
}
var _ PlannedChange = (*PlannedChangeHeader)(nil)
// PlannedChangeProto implements PlannedChange.
func (pc *PlannedChangeHeader) PlannedChangeProto() (*terraform1.PlannedChange, error) {
var raw anypb.Any
err := anypb.MarshalFrom(&raw, &tfstackdata1.PlanHeader{
TerraformVersion: pc.TerraformVersion.String(),
PrevRunStateRaw: pc.PrevRunStateRaw,
}, proto.MarshalOptions{})
if err != nil {
return nil, err
}
return &terraform1.PlannedChange{
Raw: []*anypb.Any{&raw},
}, nil
}
// PlannedChangeApplyable is a special change type we typically append at the
// end of the raw plan stream to represent that the planning process ran to
// completion without encountering any errors, and therefore the plan could
// potentially be applied.
type PlannedChangeApplyable struct {
Applyable bool
}
var _ PlannedChange = (*PlannedChangeApplyable)(nil)
// PlannedChangeProto implements PlannedChange.
func (pc *PlannedChangeApplyable) PlannedChangeProto() (*terraform1.PlannedChange, error) {
var raw anypb.Any
err := anypb.MarshalFrom(&raw, &tfstackdata1.PlanApplyable{
Applyable: pc.Applyable,
}, proto.MarshalOptions{})
if err != nil {
return nil, err
}
return &terraform1.PlannedChange{
Raw: []*anypb.Any{&raw},
Descriptions: []*terraform1.PlannedChange_ChangeDescription{
{
Description: &terraform1.PlannedChange_ChangeDescription_PlanApplyable{
PlanApplyable: pc.Applyable,
},
},
},
}, nil
}