Skip to content

Commit afdba45

Browse files
Merge 926b688 into backport/jbardin/import-expansion-validation/hardly-glowing-titmouse
2 parents 9f89f55 + 926b688 commit afdba45

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

internal/terraform/context_apply_deferred_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2915,7 +2915,7 @@ import {
29152915
wantDeferred: make(map[string]ExpectedDeferred),
29162916
wantDiagnostic: func(diags tfdiags.Diagnostics) bool {
29172917
for _, diag := range diags {
2918-
if diag.Description().Summary == "Use of import for_each in an invalid context" {
2918+
if diag.Description().Summary == "Resource has no configuration" {
29192919
return true
29202920
}
29212921
}

internal/terraform/node_resource_validate.go

-13
Original file line numberDiff line numberDiff line change
@@ -572,20 +572,7 @@ func (n *NodeValidatableResource) validateImportTargets(ctx EvalContext) tfdiags
572572
return diags
573573
}
574574

575-
// Resource config might be nil here since we are also validating config generation.
576-
expanded := n.Config != nil && (n.Config.ForEach != nil || n.Config.Count != nil)
577-
578575
if imp.Config.ForEach != nil {
579-
if !expanded {
580-
diags = diags.Append(&hcl.Diagnostic{
581-
Severity: hcl.DiagError,
582-
Summary: "Use of import for_each in an invalid context",
583-
Detail: "Use of for_each in import requires a resource using count or for_each.",
584-
// FIXME: minor issue, but this points to the for_each expression rather than for_each itself.
585-
Subject: imp.Config.ForEach.Range().Ptr(),
586-
})
587-
}
588-
589576
forEachData, _, forEachDiags := newForEachEvaluator(imp.Config.ForEach, ctx, true).ImportValues()
590577
diags = diags.Append(forEachDiags)
591578
if forEachDiags.HasErrors() {

0 commit comments

Comments
 (0)