Open Dominik-K opened 7 years ago
Hi @Dominik-K! Thanks for these ideas.
Looks like there's two different ideas packed in here:
aws_instance.server[1]
to import into something that has count
, or to module.foo.aws_instance.server
to import into a child module. I definitely take the point on the ease of implementing autocomplete there, though; we've talked before about giving Terraform a built-in autocomplete driver that could then understand the various syntaxes, but that is indeed harder than just splitting these things up separately. Something we'll have to think about...Thanks for taking the time to write this up. All good feedback here, and we'll take it into consideration once we get into the more detailed planning for improvements to import.
Thanks for your fast and detailled answer @apparentlymart.
I've just found a similar issue: it's more convenient to write
terraform state mv aws_route53_record OLD_NAME NEW_NAME
instead of
terraform state mv aws_route53_record.OLD_NAME aws_route53_record.NEW_NAME
Maybe that's a good newcomer task, isn't it?
That runs into some of the same concerns I mentioned above: the ability to move things is more general than just changing the name. Possibly we could have a shorthand that if the second argument contains no dots we automatically assume it's a new name for the first argument, leaving everything else unchanged:
terraform state mv aws_route_53_record.OLD_NAME NEW_NAME
...but I'm not sure if there would be unintended consequences for that. :confused:
I think the work here would be mainly in command/state_mv.go
. If you'd be interested in building a prototype to help think through and test for any non-obvious problems then that'd be appreciated! But I just want to be explicit that there is a conflict here that these state
commands can be potentially destructive so we have generally leaned towards being explicit, at the expense of being verbose, since that gives us better opportunity to validate the arguments and help avoid mistakes. We'd need to make sure that a change here doesn't impact our ability to do these checks.
@apparentlymart, do we want to close this issue due to its age?
A subcommand with the resource name for the
import
subcommand would be very helpful to start transforming to Terraform. As an example:instead of
import
command above from itself).