From b6a64077837acc649df577c6aeb72b37b16e6afb Mon Sep 17 00:00:00 2001 From: Liam Cervante Date: Mon, 27 Oct 2025 12:00:30 +0100 Subject: [PATCH] remember to set new opt for apply stage --- internal/moduletest/graph/apply.go | 5 +-- internal/terraform/context_apply.go | 47 ++++++++++++++--------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/internal/moduletest/graph/apply.go b/internal/moduletest/graph/apply.go index 4c2e308e2c..0c9dfa21e9 100644 --- a/internal/moduletest/graph/apply.go +++ b/internal/moduletest/graph/apply.go @@ -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) diff --git a/internal/terraform/context_apply.go b/internal/terraform/context_apply.go index e3472e8dc4..dc894b0755 100644 --- a/internal/terraform/context_apply.go +++ b/internal/terraform/context_apply.go @@ -59,7 +59,8 @@ type ApplyOpts struct { // as in test cases. func (po *PlanOpts) ApplyOpts() *ApplyOpts { return &ApplyOpts{ - ExternalProviders: po.ExternalProviders, + ExternalProviders: po.ExternalProviders, + AllowRootEphemeralOutputs: po.AllowRootEphemeralOutputs, } } @@ -299,6 +300,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) @@ -323,10 +328,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 @@ -359,26 +362,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() {