Skip to content

Commit 9371b60

Browse files
committed
More verbose error for whole resource move failure
When running state mv with a resource source, but the destination fails, provide a hint that the source is a resource (not an instance) in case the user means to address it this way
1 parent 52c77ba commit 9371b60

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎command/state_mv.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (c *StateMvCommand) Run(args []string) int {
184184
diags = diags.Append(tfdiags.Sourceless(
185185
tfdiags.Error,
186186
msgInvalidTarget,
187-
fmt.Sprintf("Cannot move %s to %s: the target must also be a whole resource.", addrFrom, destAddr),
187+
fmt.Sprintf("Cannot move %s to %s: the source is a whole resource (not a resource instance) so the target must also be a whole resource.", addrFrom, destAddr),
188188
))
189189
c.showDiagnostics(diags)
190190
return 1

‎command/state_mv_test.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,9 @@ func TestStateMv_resourceToInstanceErr(t *testing.T) {
293293
expectedErr := `
294294
Error: Invalid target address
295295
296-
Cannot move test_instance.foo to test_instance.bar[0]: the target must also be
297-
a whole resource.
296+
Cannot move test_instance.foo to test_instance.bar[0]: the source is a whole
297+
resource (not a resource instance) so the target must also be a whole
298+
resource.
298299
299300
`
300301
errOutput := ui.ErrorWriter.String()

0 commit comments

Comments
 (0)