backport of commit b6a6407783

backport/liamcervante/ephemerals/stacks-and-tests/indirectly-arriving-shrimp
Liam Cervante 4 months ago
parent 08cb3266f2
commit e73e13d514

@ -154,8 +154,9 @@ func apply(tfCtx *terraform.Context, run *configs.TestRun, module *configs.Confi
}
applyOpts := &terraform.ApplyOpts{
SetVariables: ephemeralVariables,
ExternalProviders: providers,
SetVariables: ephemeralVariables,
ExternalProviders: providers,
AllowRootEphemeralOutputs: true,
}
waiter.update(tfCtx, progress, created)

@ -52,7 +52,8 @@ type ApplyOpts struct {
// as in test cases.
func (po *PlanOpts) ApplyOpts() *ApplyOpts {
return &ApplyOpts{
ExternalProviders: po.ExternalProviders,
ExternalProviders: po.ExternalProviders,
AllowRootEphemeralOutputs: po.AllowRootEphemeralOutputs,
}
}
@ -292,6 +293,10 @@ func checkApplyTimeVariables(needed collections.Set[string], gotValues InputValu
func (c *Context) applyGraph(plan *plans.Plan, config *configs.Config, opts *ApplyOpts, validate bool) (*Graph, walkOperation, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
if opts == nil {
opts = new(ApplyOpts)
}
variables := InputValues{}
for name, dyVal := range plan.VariableValues {
val, err := dyVal.Decode(cty.DynamicPseudoType)
@ -316,10 +321,8 @@ func (c *Context) applyGraph(plan *plans.Plan, config *configs.Config, opts *App
// FIXME: We should check that all of these match declared variables and
// that all of them are declared as ephemeral, because all non-ephemeral
// variables are supposed to come exclusively from plan.VariableValues.
if opts != nil {
for n, vv := range opts.SetVariables {
variables[n] = vv
}
for n, vv := range opts.SetVariables {
variables[n] = vv
}
if diags.HasErrors() {
return nil, walkApply, diags
@ -352,26 +355,22 @@ func (c *Context) applyGraph(plan *plans.Plan, config *configs.Config, opts *App
operation = walkDestroy
}
var externalProviderConfigs map[addrs.RootProviderConfig]providers.Interface
if opts != nil {
externalProviderConfigs = opts.ExternalProviders
}
graph, moreDiags := (&ApplyGraphBuilder{
Config: config,
Changes: plan.Changes,
DeferredChanges: plan.DeferredResources,
State: plan.PriorState,
RootVariableValues: variables,
ExternalProviderConfigs: externalProviderConfigs,
Plugins: c.plugins,
Targets: plan.TargetAddrs,
ActionTargets: plan.ActionTargetAddrs,
ForceReplace: plan.ForceReplaceAddrs,
Operation: operation,
ExternalReferences: plan.ExternalReferences,
Overrides: plan.Overrides,
SkipGraphValidation: c.graphOpts.SkipGraphValidation,
Config: config,
Changes: plan.Changes,
DeferredChanges: plan.DeferredResources,
State: plan.PriorState,
RootVariableValues: variables,
ExternalProviderConfigs: opts.ExternalProviders,
Plugins: c.plugins,
Targets: plan.TargetAddrs,
ActionTargets: plan.ActionTargetAddrs,
ForceReplace: plan.ForceReplaceAddrs,
Operation: operation,
ExternalReferences: plan.ExternalReferences,
Overrides: plan.Overrides,
SkipGraphValidation: c.graphOpts.SkipGraphValidation,
AllowRootEphemeralOutputs: opts.AllowRootEphemeralOutputs,
}).Build(addrs.RootModuleInstance)
diags = diags.Append(moreDiags)
if moreDiags.HasErrors() {

Loading…
Cancel
Save