diff --git a/internal/command/import.go b/internal/command/import.go index a576a29e4047..d897868be52a 100644 --- a/internal/command/import.go +++ b/internal/command/import.go @@ -45,7 +45,6 @@ func (c *ImportCommand) Run(args []string) int { cmdFlags.StringVar(&configPath, "config", pwd, "path") cmdFlags.BoolVar(&c.Meta.stateLock, "lock", true, "lock state") cmdFlags.DurationVar(&c.Meta.stateLockTimeout, "lock-timeout", 0, "lock timeout") - cmdFlags.BoolVar(&c.Meta.allowMissingConfig, "allow-missing-config", false, "allow missing config") cmdFlags.Usage = func() { c.Ui.Error(c.Help()) } if err := cmdFlags.Parse(args); err != nil { return 1 @@ -135,7 +134,7 @@ func (c *ImportCommand) Run(args []string) int { break } } - if !c.Meta.allowMissingConfig && rc == nil { + if rc == nil { modulePath := addr.Module.String() if modulePath == "" { modulePath = "the root module" @@ -262,10 +261,6 @@ func (c *ImportCommand) Run(args []string) int { c.Ui.Output(c.Colorize().Color("[reset][green]\n" + importCommandSuccessMsg)) - if c.Meta.allowMissingConfig && rc == nil { - c.Ui.Output(c.Colorize().Color("[reset][yellow]\n" + importCommandAllowMissingResourceMsg)) - } - c.showDiagnostics(diags) if diags.HasErrors() { return 1 @@ -310,8 +305,6 @@ Options: If no config files are present, they must be provided via the input prompts or env vars. - -allow-missing-config Allow import when no resource configuration block exists. - -input=false Disable interactive input prompts. -lock=false Don't hold a state lock during the operation. This is diff --git a/internal/command/import_test.go b/internal/command/import_test.go index f81658223b2b..8c4744c5d992 100644 --- a/internal/command/import_test.go +++ b/internal/command/import_test.go @@ -644,63 +644,6 @@ func TestImport_providerConfigWithVarFile(t *testing.T) { testStateOutput(t, statePath, testImportStr) } -func TestImport_allowMissingResourceConfig(t *testing.T) { - defer testChdir(t, testFixturePath("import-missing-resource-config"))() - - statePath := testTempFile(t) - - p := testProvider() - ui := new(cli.MockUi) - view, _ := testView(t) - c := &ImportCommand{ - Meta: Meta{ - testingOverrides: metaOverridesForProvider(p), - Ui: ui, - View: view, - }, - } - - p.ImportResourceStateFn = nil - p.ImportResourceStateResponse = &providers.ImportResourceStateResponse{ - ImportedResources: []providers.ImportedResource{ - { - TypeName: "test_instance", - State: cty.ObjectVal(map[string]cty.Value{ - "id": cty.StringVal("yay"), - }), - }, - }, - } - p.GetProviderSchemaResponse = &providers.GetProviderSchemaResponse{ - ResourceTypes: map[string]providers.Schema{ - "test_instance": { - Block: &configschema.Block{ - Attributes: map[string]*configschema.Attribute{ - "id": {Type: cty.String, Optional: true, Computed: true}, - }, - }, - }, - }, - } - - args := []string{ - "-state", statePath, - "-allow-missing-config", - "test_instance.foo", - "bar", - } - - if code := c.Run(args); code != 0 { - t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) - } - - if !p.ImportResourceStateCalled { - t.Fatal("ImportResourceState should be called") - } - - testStateOutput(t, statePath, testImportStr) -} - func TestImport_emptyConfig(t *testing.T) { defer testChdir(t, testFixturePath("empty"))()