Commit Graph

20 Commits

Author SHA1 Message Date
Jack Bruno 3f2136d7ee cli: terraform import -ignore-missing-config
This new option allows importing without configuration present.

Configuration is required by default as a confirmation that the provided resource name is correct, but it can be useful to override this in tools that wrap Terraform to do more involved operations.
2017-09-18 11:41:30 -07:00
James Bardin 4034f988df update import command docs
Fix the -state and -state-out wording to be consistent with other
commands. Remove the erroneous reference to remote state in the website
version of the flag description.
2017-08-09 14:01:45 -04:00
James Bardin e3748901b4 Don't ForceLocal for the import backend
While the `local.Local` backend is the only implementation of
`backend.Local`, creating the backend with `ForceLocal` bypasses the
`backend.Backend` in the `local.Local` causing a local state to be
implicitly created rather than using the configured state backend.

Add a test that imports into a configured backend (using the "local"
backend as a remote state proxy). This further confirms the confusing
nature of ForceLocal, as the backend _is_ local, but not from the
viewpoint of meta.Backend.
2017-08-09 10:24:32 -04:00
Robert Liebowitz 8d98fdecac Autoload only .auto.tfvars files 2017-07-05 17:24:17 -07:00
Robert Liebowitz 006744bfe0 Use all tfvars files in working directory
As a side effect, several commands that previously did not have a failure
state can now fail during meta-parameter processing.
2017-07-05 17:24:17 -07:00
James Bardin 0cbd51c365 find -plugin-dir during import
The import command wasn't loading the plugin path at all, relying on the
local directory for binaries.

Load the plugin dir into Meta, and pass in ForceLocal for consistency.
The Backend returned was going to be a Local anyway, so the added check
wasn't ensuring anything.
2017-06-26 18:28:45 -04:00
Martin Atkins 9a398a7793 command: require resource to be in config before import
Previously we encouraged users to import a resource and _then_ write the
configuration block for it. This ordering creates lots of risk, since
for various reasons users can end up subsequently running Terraform
without any configuration in place, which then causes Terraform to want
to destroy the resource that was imported.

Now we invert this and require a minimal configuration block be written
first. This helps ensure that the user ends up with a correlated resource
config and state, protecting against any inconsistency caused by typos.

This addresses #11835.
2017-06-09 14:03:59 -07:00
Martin Atkins 7d8719150c command: validate import resource address early
Previously we deferred validation of the resource address on the import
command until we were in the core guts, which caused the error responses
to be rather unhelpful.

By validating these things early we can give better feedback to the user.
2017-06-09 14:03:59 -07:00
James Bardin 718ede0636 have Meta.Backend use a Config rather than loading
Instead of providing the a path in BackendOpts, provide a loaded
*config.Config instead. This reduces the number of places where
configuration is loaded.
2017-06-09 14:03:59 -07:00
James Bardin 5eca913b14 add cli flags for -lock-timeout
Add the -lock-timeout flag to the appropriate commands.
Add the -lock flag to `init` and `import` which were missing it.
Set both stateLock and stateLockTimeout in Meta.flagsSet, and remove the
extra references for clarity.
2017-04-01 17:09:21 -04:00
Mitchell Hashimoto ad7b063262
command: convert to use backends 2017-01-26 14:33:49 -08:00
Mitchell Hashimoto f84fd39ef9
command/import: document -var-file and -var is available #11211 2017-01-24 13:02:54 -08:00
Mitchell Hashimoto 28d933f6dd
nitpicks for #10310 2016-11-23 09:40:11 -08:00
Daniel Spangenberg 804a5bd3c5 Implements import with specified provider
This allows the import with a specified provider.
So far it was not possible to get resources imported from a different provider
than the default.
2016-11-23 11:58:58 +01:00
Mitchell Hashimoto f8ec7dad19
command/import: allow the -config flag to specify a config location 2016-11-09 15:09:13 -08:00
Mitchell Hashimoto ec0ef95c6f
terraform: verify import providers only depend on vars 2016-11-09 15:09:13 -08:00
Mitchell Hashimoto 5107c33119
command/import: load configurations and allow empty config dirs
Fixes #7774

This modifies the `import` command to load configuration files from the
pwd. This also augments the configuration loading section for the CLI to
have a new option (default false, same as old behavior) to
allow directories with no Terraform configurations.
For import, we allow directories with no Terraform configurations so
this option is set to true.
2016-11-09 15:08:22 -08:00
Mitchell Hashimoto f6a59734ef
command: UI for import 2016-05-11 13:02:35 -07:00
Mitchell Hashimoto 182a8a28c0
command/import more wip 2016-05-11 13:02:33 -07:00
Mitchell Hashimoto ff94381e7e
command/import wip 2016-05-11 13:02:33 -07:00