Skip to content

Commit 4981942

Browse files
committed
remove -allow-missing-config from import
1 parent 03fc2b0 commit 4981942

File tree

3 files changed

+1
-77
lines changed

3 files changed

+1
-77
lines changed

internal/command/import.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ func (c *ImportCommand) Run(args []string) int {
4545
cmdFlags.StringVar(&configPath, "config", pwd, "path")
4646
cmdFlags.BoolVar(&c.Meta.stateLock, "lock", true, "lock state")
4747
cmdFlags.DurationVar(&c.Meta.stateLockTimeout, "lock-timeout", 0, "lock timeout")
48-
cmdFlags.BoolVar(&c.Meta.allowMissingConfig, "allow-missing-config", false, "allow missing config")
4948
cmdFlags.Usage = func() { c.Ui.Error(c.Help()) }
5049
if err := cmdFlags.Parse(args); err != nil {
5150
return 1
@@ -135,7 +134,7 @@ func (c *ImportCommand) Run(args []string) int {
135134
break
136135
}
137136
}
138-
if !c.Meta.allowMissingConfig && rc == nil {
137+
if rc == nil {
139138
modulePath := addr.Module.String()
140139
if modulePath == "" {
141140
modulePath = "the root module"
@@ -262,10 +261,6 @@ func (c *ImportCommand) Run(args []string) int {
262261

263262
c.Ui.Output(c.Colorize().Color("[reset][green]\n" + importCommandSuccessMsg))
264263

265-
if c.Meta.allowMissingConfig && rc == nil {
266-
c.Ui.Output(c.Colorize().Color("[reset][yellow]\n" + importCommandAllowMissingResourceMsg))
267-
}
268-
269264
c.showDiagnostics(diags)
270265
if diags.HasErrors() {
271266
return 1
@@ -310,8 +305,6 @@ Options:
310305
If no config files are present, they must be provided
311306
via the input prompts or env vars.
312307
313-
-allow-missing-config Allow import when no resource configuration block exists.
314-
315308
-input=false Disable interactive input prompts.
316309
317310
-lock=false Don't hold a state lock during the operation. This is
@@ -361,12 +354,3 @@ const importCommandSuccessMsg = `Import successful!
361354
The resources that were imported are shown above. These resources are now in
362355
your Terraform state and will henceforth be managed by Terraform.
363356
`
364-
365-
const importCommandAllowMissingResourceMsg = `Import does not generate resource configuration, you must create a resource
366-
configuration block that matches the current or desired state manually.
367-
368-
If there is no matching resource configuration block for the imported
369-
resource, Terraform will delete the resource on the next "terraform apply".
370-
It is recommended that you run "terraform plan" to verify that the
371-
configuration is correct and complete.
372-
`

internal/command/import_test.go

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -644,63 +644,6 @@ func TestImport_providerConfigWithVarFile(t *testing.T) {
644644
testStateOutput(t, statePath, testImportStr)
645645
}
646646

647-
func TestImport_allowMissingResourceConfig(t *testing.T) {
648-
defer testChdir(t, testFixturePath("import-missing-resource-config"))()
649-
650-
statePath := testTempFile(t)
651-
652-
p := testProvider()
653-
ui := new(cli.MockUi)
654-
view, _ := testView(t)
655-
c := &ImportCommand{
656-
Meta: Meta{
657-
testingOverrides: metaOverridesForProvider(p),
658-
Ui: ui,
659-
View: view,
660-
},
661-
}
662-
663-
p.ImportResourceStateFn = nil
664-
p.ImportResourceStateResponse = &providers.ImportResourceStateResponse{
665-
ImportedResources: []providers.ImportedResource{
666-
{
667-
TypeName: "test_instance",
668-
State: cty.ObjectVal(map[string]cty.Value{
669-
"id": cty.StringVal("yay"),
670-
}),
671-
},
672-
},
673-
}
674-
p.GetProviderSchemaResponse = &providers.GetProviderSchemaResponse{
675-
ResourceTypes: map[string]providers.Schema{
676-
"test_instance": {
677-
Block: &configschema.Block{
678-
Attributes: map[string]*configschema.Attribute{
679-
"id": {Type: cty.String, Optional: true, Computed: true},
680-
},
681-
},
682-
},
683-
},
684-
}
685-
686-
args := []string{
687-
"-state", statePath,
688-
"-allow-missing-config",
689-
"test_instance.foo",
690-
"bar",
691-
}
692-
693-
if code := c.Run(args); code != 0 {
694-
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
695-
}
696-
697-
if !p.ImportResourceStateCalled {
698-
t.Fatal("ImportResourceState should be called")
699-
}
700-
701-
testStateOutput(t, statePath, testImportStr)
702-
}
703-
704647
func TestImport_emptyConfig(t *testing.T) {
705648
defer testChdir(t, testFixturePath("empty"))()
706649

internal/command/meta.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,6 @@ type Meta struct {
213213
migrateState bool
214214
compactWarnings bool
215215

216-
// Used with the import command to allow import of state when no matching config exists.
217-
allowMissingConfig bool
218-
219216
// Used with commands which write state to allow users to write remote
220217
// state even if the remote and local Terraform versions don't match.
221218
ignoreRemoteVersion bool

0 commit comments

Comments
 (0)