Conversation
`Config` in ImportOpts was any provider configuration provided by the user on the command line. This option has already been removed in favor of only taking the provider from the configuration loaded in the current context.
to get the resource provider FQN from the Config
| provider["registry.terraform.io/-/aws"] | ||
| module.child.aws_instance.foo (import id "bar") | ||
| provider["registry.terraform.io/-/aws"] | ||
| module.child.module.nested.aws_instance.foo |
There was a problem hiding this comment.
Where is this nested instance coming from? I don't see it in the test above
There was a problem hiding this comment.
Ah, I see it now, it's in the new config. Should this be showing up here, since we're not importing it?
There was a problem hiding this comment.
I got the impression that it's expected to show the entire state, not just what was imported. Does that match your expectation? (the previous version of this test was importing into an empty config).
There was a problem hiding this comment.
This is the graph, and not the state however. I would do some tests to see what happens when you import 1 resource, but there are other resources in the config (both existent and non-existent). This might be fine and we can fix it later, but I'm afraid that this might error out once the import process starts.
There was a problem hiding this comment.
Smoke test w/a config with two random_ids, one existing in state and the other not:
$terraform import random_id.dos TdTfsRX6g4o
random_id.dos: Importing from ID "TdTfsRX6g4o"...
random_id.dos: Import prepared!
Prepared random_id for import
random_id.dos: Refreshing state... [id=TdTfsRX6g4o]
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
$ terraform import random_id.nonexist TdTfsRX6g4o
Error: resource address "random_id.nonexist" does not exist in the configuration.
Before importing this resource, please create its configuration in the root module. For example:
resource "random_id" "nonexist" {
# (resource arguments)
}|
@jbardin I may need to pick your brain on the failing tests in [UPDATE]: we spoke about this offline; the tests were invalid as written (as many of the tests modified in this PR, they depended on importing without config, which is not valid) so we removed them. |
533b4da to
5ea0926
Compare
Codecov Report
|
|
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
There are several changes in the tests, so this might be easier to read commit-by-commit - the first two commits contain the bulk of the changes and the last commit contains test updates.
I've left several hopefully-obvious "QUESTION" comments in a couple of places.
I'm concerned about the changes in the provider transformer tests - I will see what codecov has to say about my changes, but several of those tests depended on importing resources (and modules) into empy configuration. Once I refactored import to require configuration that stopped working, and made a few tests appear redundant. 🤷♀