Skip to content

Commit 8abf895

Browse files
committed
fix to expression target error
1 parent 88a9b79 commit 8abf895

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

internal/terraform/eval_import.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,18 @@ func evalImportToExpression(expr hcl.Expression, keyData instances.RepetitionDat
9090
return res, targetDiags
9191
}
9292

93-
// FIXME: check that these are the only types that can be returned
9493
switch sub := target.Subject.(type) {
9594
case addrs.AbsResource:
9695
res = sub.Instance(addrs.NoKey)
9796
case addrs.AbsResourceInstance:
9897
res = sub
9998
default:
100-
panic(fmt.Sprintf("%#v\n", sub))
99+
diags = diags.Append(&hcl.Diagnostic{
100+
Severity: hcl.DiagError,
101+
Summary: "Invalid import 'to' expression",
102+
Detail: fmt.Sprintf("The import block 'to' argument %s does not resolve to a single resource instance.", sub),
103+
Subject: expr.Range().Ptr(),
104+
})
101105
}
102106

103107
return res, diags
@@ -182,7 +186,7 @@ func parseImportToKeyExpression(expr hcl.Expression, keyData instances.Repetitio
182186
if val.HasMark(marks.Sensitive) {
183187
diags = diags.Append(&hcl.Diagnostic{
184188
Severity: hcl.DiagError,
185-
Summary: "Invalid index expressions",
189+
Summary: "Invalid index expression",
186190
Detail: "Import address index expression cannot be sensitive.",
187191
Subject: expr.Range().Ptr(),
188192
})

0 commit comments

Comments
 (0)