diff --git a/internal/terraform/node_module_install.go b/internal/terraform/node_module_install.go index 49a390df15..0fd64619e4 100644 --- a/internal/terraform/node_module_install.go +++ b/internal/terraform/node_module_install.go @@ -73,6 +73,12 @@ func (n *nodeInstallModule) References() []*addrs.Reference { func (n *nodeInstallModule) Execute(ctx EvalContext, walkOp walkOperation) tfdiags.Diagnostics { var diags tfdiags.Diagnostics + if n.ModuleCall.SourceExpr == nil { + // Cannot install a module without a source + // Outer diags should already contain a parsing error + return diags + } + var version configs.VersionConstraint hasVersion := false if n.ModuleCall.VersionExpr != nil { @@ -141,6 +147,12 @@ func (n *nodeInstallModule) DynamicExpand(ctx EvalContext) (*Graph, tfdiags.Diag var g Graph var diags tfdiags.Diagnostics + if n.Config == nil { + // Cannot expand without a config. This can happen when something goes wrong + // during module installation/Execute() above. + return nil, diags + } + expander := ctx.InstanceExpander() _, call := n.Addr.Call() expander.SetModuleSingle(n.Path(), call)