stackeval: Emit PlannedChange for each component instance

We need to explicitly announce each component instance that we find
declared in the stack configuration before we announce any resource
instances that belong to it, because callers will rely on this message to
create a link between the component instance address on each resource
instance and the unexpanded component addresses previously announced by
the "find stack components" static analysis call.
pull/34738/head
Martin Atkins 3 years ago
parent 2d2baee72d
commit fbc34005ba

@ -269,6 +269,17 @@ func (c *ComponentInstance) PlanChanges(ctx context.Context) ([]stackplan.Planne
var changes []stackplan.PlannedChange
var diags tfdiags.Diagnostics
// We must always at least announce that the component instance exists,
// and that must come before any resource instance changes referring to it.
changes = append(changes, &stackplan.PlannedChangeComponentInstance{
Addr: c.Addr(),
// FIXME: Once we actually have a prior state this should vary
// depending on whether the same component instance existed in
// the prior state.
Action: plans.Create,
})
_, moreDiags := c.CheckInputVariableValues(ctx, PlanPhase)
diags = diags.Append(moreDiags)

@ -51,6 +51,15 @@ func TestPlanWithSingleResource(t *testing.T) {
&stackplan.PlannedChangeApplyable{
Applyable: true,
},
&stackplan.PlannedChangeComponentInstance{
Addr: stackaddrs.Absolute(
stackaddrs.RootStackInstance,
stackaddrs.ComponentInstance{
Component: stackaddrs.Component{Name: "self"},
},
),
Action: plans.Create,
},
&stackplan.PlannedChangeHeader{
TerraformVersion: version.SemVer,
},

Loading…
Cancel
Save