diff --git a/terraform/context_import_test.go b/terraform/context_import_test.go index 908d714f3..a86893915 100644 --- a/terraform/context_import_test.go +++ b/terraform/context_import_test.go @@ -108,7 +108,7 @@ func TestContextImport_module(t *testing.T) { } actual := strings.TrimSpace(state.String()) - expected := strings.TrimSpace(testImportRefreshStr) + expected := strings.TrimSpace(testImportModuleStr) if actual != expected { t.Fatalf("bad: \n%s", actual) } @@ -120,6 +120,14 @@ aws_instance.foo: provider = aws ` +const testImportModuleStr = ` + +module.foo: + aws_instance.foo: + ID = foo + provider = aws +` + const testImportRefreshStr = ` aws_instance.foo: ID = foo diff --git a/terraform/transform_import_state.go b/terraform/transform_import_state.go index 71ac6fbe0..f99af7c64 100644 --- a/terraform/transform_import_state.go +++ b/terraform/transform_import_state.go @@ -51,7 +51,7 @@ func (n *graphNodeImportState) ProvidedBy() []string { // GraphNodeSubPath func (n *graphNodeImportState) Path() []string { - return n.Addr.Path + return normalizeModulePath(n.Addr.Path) } // GraphNodeEvalable impl. @@ -59,7 +59,7 @@ func (n *graphNodeImportState) EvalTree() EvalNode { var provider ResourceProvider info := &InstanceInfo{ Id: n.ID, - ModulePath: n.Addr.Path, + ModulePath: n.Path(), Type: n.Addr.Type, } @@ -126,6 +126,10 @@ func (n *graphNodeImportStateSub) Name() string { return fmt.Sprintf("import %s result: %s", n.Target, n.State.ID) } +func (n *graphNodeImportStateSub) Path() []string { + return n.Path_ +} + // GraphNodeEvalable impl. func (n *graphNodeImportStateSub) EvalTree() EvalNode { // If the Ephemeral type isn't set, then it is an error