@@ -16,13 +16,22 @@ type ImportCommand struct {
1616}
1717
1818func (c * ImportCommand ) Run (args []string ) int {
19+ // Get the pwd since its our default -config flag value
20+ pwd , err := os .Getwd ()
21+ if err != nil {
22+ c .Ui .Error (fmt .Sprintf ("Error getting pwd: %s" , err ))
23+ return 1
24+ }
25+
26+ var configPath string
1927 args = c .Meta .process (args , true )
2028
2129 cmdFlags := c .Meta .flagSet ("import" )
2230 cmdFlags .IntVar (& c .Meta .parallelism , "parallelism" , 0 , "parallelism" )
2331 cmdFlags .StringVar (& c .Meta .statePath , "state" , DefaultStateFilename , "path" )
2432 cmdFlags .StringVar (& c .Meta .stateOutPath , "state-out" , "" , "path" )
2533 cmdFlags .StringVar (& c .Meta .backupPath , "backup" , "" , "path" )
34+ cmdFlags .StringVar (& configPath , "config" , pwd , "path" )
2635 cmdFlags .Usage = func () { c .Ui .Error (c .Help ()) }
2736 if err := cmdFlags .Parse (args ); err != nil {
2837 return 1
@@ -35,15 +44,9 @@ func (c *ImportCommand) Run(args []string) int {
3544 return 1
3645 }
3746
38- pwd , err := os .Getwd ()
39- if err != nil {
40- c .Ui .Error (fmt .Sprintf ("Error getting pwd: %s" , err ))
41- return 1
42- }
43-
4447 // Build the context based on the arguments given
4548 ctx , _ , err := c .Context (contextOpts {
46- Path : pwd ,
49+ Path : configPath ,
4750 PathEmptyOk : true ,
4851 StatePath : c .Meta .statePath ,
4952 Parallelism : c .Meta .parallelism ,
@@ -120,6 +123,11 @@ Options:
120123 modifying. Defaults to the "-state-out" path with
121124 ".backup" extension. Set to "-" to disable backup.
122125
126+ -config=path Path to a directory of Terraform configuration files
127+ to use to configure the provider. Defaults to pwd.
128+ If no config files are present, they must be provided
129+ via the input prompts or env vars.
130+
123131 -input=true Ask for input for variables if not directly set.
124132
125133 -no-color If specified, output won't contain any color.
0 commit comments